执行 Robolectric JUnit 4 测试用例时出现初始化错误
initializationError while executing Robolectric JUnit 4 test case
我在执行 Robolectric JUnit 4 测试用例时遇到初始化错误。
开发 IDE:Eclipse Indigo 3.7.2
java.lang.NoClassDefFoundError: org/robolectric/annotation/Config
请在下面找到我的测试用例的源代码:
@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));
}
}
我刚刚通过添加 robolectric-2.3-jar-with-dependencies.jar 解决了这个问题并删除了现有的 robolectric-3.0-rc3.jar 来自 Android 项目构建路径
我在执行 Robolectric JUnit 4 测试用例时遇到初始化错误。
开发 IDE:Eclipse Indigo 3.7.2
java.lang.NoClassDefFoundError: org/robolectric/annotation/Config
请在下面找到我的测试用例的源代码:
@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));
}
}
我刚刚通过添加 robolectric-2.3-jar-with-dependencies.jar 解决了这个问题并删除了现有的 robolectric-3.0-rc3.jar 来自 Android 项目构建路径