You need to adjust the launch configuration.
If you want to run the JUnit test with
"right click on test class in the package explorer"->"Run As"->"JUnit Test"
in an Android project, you need to install the “Android JUnit Test Launcher” as the launch. You use this Android launcher even if your launch configuration is of type “JUnit”.
You can find it under:
"right click on test class in the package explorer"->"Properties"->"Run/Debug Settings"->"Edit..."
An example :
Test:
import junit.framework.TestCase; public class ExampleTest extends TestCase{ public ExampleTest(String name){ super(name); } protected void setUp() throws Exception{ super.setUp(); } protected void tearDown() throws Exception{ super.tearDown(); } public void testFoo(){ fail("Not yet implemented"); }
}
Create a launch configuration:
"Run"->"Run Configurations..."->"Right click on JUnit"->"New"->"Set project and Test class"->"Select Android JUnit Test Launcher"->"Run"
Note. If you use x86 jdk, you will get the following error if your Launcher is installed in "Eclipse JUnit Launcher":
Invalid layout of java.lang.String at value
Limentaris Apr 05 '13 at 17:56
source share