温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Robotium 运行报错解析

发布时间:2020-07-21 10:30:29 来源:网络 阅读:653 作者:歇菜了再见 栏目:移动开发

初学robotium 

运行后,遇到问题如下:


junit.framework.AssertionFailedError: No tests found in com.example.zoe.test.ZoeTest

at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)

at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)

at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)

at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1741)



1.将用例方法名前面添加test ,例如 li()改为 testLi()



java.lang.NoClassDefFoundError: com.robotium.solo.Solo

at com.example.zoe.test.ZoeTest.setUp(ZoeTest.java:24)

at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)

at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)

at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)

at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1741)

2 .在properties 选择order 和export 里面将Robotium.jar包置顶 就解决了



java.lang.NullPointerException

at android.test.InstrumentationTestCase.launchActivityWithIntent(InstrumentationTestCase.java:117)

at android.test.InstrumentationTestCase.launchActivity(InstrumentationTestCase.java:97)

at android.test.ActivityInstrumentationTestCase2.getActivity(ActivityInstrumentationTestCase2.java:104)

at com.example.zoe.test.ZoeTest.setUp(ZoeTest.java:24)

at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)

at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)

at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)

at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1741)


1.没有找到要测试activity 的对应主包名 


junit.framework.AssertionFailedError: 没有找到完成 expected:<true> but was:<false>

at com.example.zoe.test.ZoeTest.testButton(ZoeTest.java:32)

at java.lang.reflect.Method.invokeNative(Native Method)

at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)

at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)

at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)

at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)

at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)

at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)

at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1741)


1.断言格式错误。



junit.framework.AssertionFailedError: The specified Activity is null!

at com.robotium.solo.Asserter.assertCurrentActivity(Asserter.java:60)

at com.robotium.solo.Solo.assertCurrentActivity(Solo.java:989)

at com.example.zoe.test.ZoeTest.testButton(ZoeTest.java:34)

at java.lang.reflect.Method.invokeNative(Native Method)

at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)

at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)

at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)

at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)

at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)

at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)

at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1741)


solo.assertCurrentActivity("expect test activity","Zoe" );  未使用正确

                    "message","应用名称"


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI