与Robotium进行junit测试时的AssertionFailedError

时间:2012-12-13 09:16:01

标签: java android exception junit

我在每次测试时都会遇到以下异常,我无法弄清楚原因。希望有人有一些见解。

 ----- begin exception -----
junit.framework.AssertionFailedError: 
Activity named mainActivity can not be returned to
at junit.framework.Assert.fail(Assert.java:47)
at junit.framework.Assert.assertTrue(Assert.java:20)
at com.jayway.android.robotium.solo.ActivityUtils.goBackToActivity(ActivityUtils.java:185)
at com.jayway.android.robotium.solo.Solo.goBackToActivity(Solo.java:1864)
at com.package.test.AppointmentSettingTestBase.tearDown(AppointmentSettingTestBase.java:64)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:525)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1547)

-----结束例外-----

1 个答案:

答案 0 :(得分:1)

您已编写了要返回的活动的正确名称。我认为您的活动名称是MainActivity而不是mainActivity。