0
我试图运行Roboelectric单元测试来测试,如果预期的活动入门与否,但我发现了以下错误:NoClassDefFoundError的同时运行Roboelectric单元测试
java.lang.NoClassDefFoundError: Could not initialize class android.os.AsyncTask
我要找为解决方案,但目前为止没有运气,有没有人遇到过这个问题。
找到我下面的测试类
@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class, manifest = "AndroidManifest.xml", minSdk = 21, maxSdk = 21, application = MyApplication.class)
@PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "android.*"})
public class PushManagerTest {
@Test
public void shouldLaunchNewActivity() throws Exception {
Activity testActivity = Robolectric.setupActivity(TestActivity.class);
Intent expectedIntent = new Intent(testActivity, NewActivity.class);
Intent actualIntent = ShadowApplication.getInstance().getNextStartedActivity();
assertEquals(expectedIntent.getComponent(), actualIntent.getComponent());
}
}
为什么你需要'PowerMock'? –
对于运行某个其他测试,它与此测试用例无关,但我需要它在我的套件中运行其他测试 – Ezio
对于运行某个其他测试,它与此测试用例无关,但我需要它运行其他测试在我的套件中进行测试 – Ezio