initializationError while executing Robolectric JUnit 4 test case

625 views Asked by At

I am facing initializationError while executing Robolectric JUnit 4 test case.
Development IDE : Eclipse Indigo 3.7.2

java.lang.NoClassDefFoundError: org/robolectric/annotation/Config

Please find source code of my test case below:

@RunWith(RobolectricTestRunner.class)
public class MainActivityTest {

    @Test
    public void clickingSplashVideo_shouldStartCategoryActivity() throws Exception {

        MainActivity activity = Robolectric.setupActivity(MainActivity.class);
        activity.findViewById(R.id.myvideoview).performClick();

        String hello = activity.getString(R.string.app_name);
        assertThat(hello, CoreMatchers.equalTo("Hello world!"));

        Intent expectedIntent = new Intent(activity, CategoryActivity.class);
        assertThat(Shadows.shadowOf(activity).getNextStartedActivity(), CoreMatchers.equalTo(expectedIntent));
    }
}
1

There are 1 answers

1
Durgesh Patel On BEST ANSWER

I just solved this problem by adding robolectric-2.3-jar-with-dependencies.jar and removed existing robolectric-3.0-rc3.jar from Android project build path