Can't run JUnit 4 test case in Eclipse Android project
Having searched Google for an answer, this looks like it might have something to do with Android development tools.
Below are steps taken from this comment thread:
- Right click on the project -> run -> run configuration
- Select your Junit project
- Go to the classpath tab
- remove the Android framework entry
- select bootstrap entries
- click on advanced
- select Add Library
- Ok
- Chose "JRE System Library"
- Next
- finish
- You need to also add the JUnit library so follow the steps 5 to 11 and select the "Junit" instead of "JRE System Library"
- You can now run your project as Junit.
No JUnit tests found' in Eclipse
Right Click on Project > Properties > Java Build Path > Add the Test folder as source folder.
All source folders including Test Classes need to be in Eclipse Java Build Path. So that the sources such as main and test classes can be compiled into the build directory (Eclipse default folder is bin).
can't find run as junit test in eclipse
Make sure your eclipse environment is using JUnit 4. JUnit 3 doesn't make use of annotations (it uses the old extends TestCase
style)
There are few things to double check:
Window > Preferences > Java > JUnit
Are you seeing junit4
or junit3
imports? If that looks good, make sure the project itself is using JUnit4 instead of JUnit3.
Right Click on project > Properties > Java Build Path > Libraries
Is JUnit4 included there? Is anything JUnit related there? If JUnit3 is in there, click on it and click Remove
. Then click Add Library...
and follow the prompts from there to add JUnit again.
Out of curiosity, are the JUnits run outside of eclipse? Like with a mvn install
or whatever build target you have for Ant that'll run JUnits
JUnit test won't run when I Run-As from the test.java file
This sort of problem is always difficult to debug without your full environment, but it sounds like you have a Run Configuration which is corrupted or doesn't match your classes or something like that. Try deleting the Run Configuration and retrying.
When you select Run As JUnit, Eclipse creates a Run Configuration specific to your JUnit class.
To fix this, in Eclipse, open Run->Run Configuration. In the list at the left, find the run configuration that applies to QuaternionTest, make sure it's the Run Configuration in the JUnit section. Delete it (right click, select delete). Then try again.
Related Topics
How to Have the Code Pause for a Couple of Seconds in Android
Polygon Touch Detection Google Map API V2
How to Get Country Phone Prefix from Iso
Sending Http Post Request with Android
Android Resource Not Found Exception
Android Proguard JavaScript Interface Fail
How to Convert Rgb Color to Int in Java
How to Resume Android Activity Programmatically from Background
Apache Httpclient Digest Authentication
Unhandled Exception Type Error
Curly Braces in "New" Expression? (E.G. "New Myclass() { ... }")
How to Change Size of Title's Text on Action Bar
:App:Dexdebug Execexception Finished with Non-Zero Exit Value 2
Java.Lang.Noclassdeffounderror: Com.Google.Ads.Adview
Android - How to Create Clickable Listview
Google Sign in Signed APK Not Working
Serializing and De-Serializing Android.Graphics.Bitmap in Java