I\'m trying run a test with JUnit 4 and Robolectric on Eclipse but all time I receive this error:
Invalid layout of java.lang.String at value
#
# A fatal err
You need to correct your run configuration.
If you want to run an JUnit test with
"right click on test class in the package explorer"->"Run As"->"JUnit Test"
on an android project, you need to set the "Android JUnit Test Launcher" as launcher. You have do use that android launcher even if your launch configuration has the type "JUnit".
You can find it under:
"right click on test class in the package explorer"->"Properties"->"Run/Debug Settings"->"Edit..."
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 run configuration:
"Run"->"Run Configurations..."->"Right click on JUnit"->"New"->"Set project and Test class"->"Select Android JUnit Test Launcher"->"Run"
Notice: If you are using an x86 jdk you will get the following error if your Launcher is set to "Eclipse JUnit Launcher":
Invalid layout of java.lang.String at value
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (javaClasses.cpp:129), pid=3844, tid=4828
# fatal error: Invalid layout of preloaded class
#
# JRE version: 7.0_17-b02
# Java VM: Java HotSpot(TM) Client VM (23.7-b01 mixed mode windows-x86 )
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows