使用andriod robotium报错,请指导

0
Android Java C/C++ Go 9785 次浏览

写了一个简单的页面,对这个页面使用robotium做测试


 没有报错,但在运行android junit test时出现了错误 


failuer trace具体如下:
java.lang.RuntimeException: Exception during suite construction
at android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests.testSuiteConstructionFailed(TestSuiteBuilder.java:238)
at java.lang.reflect.Method.invokeNative(Native Method)
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:1701)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.test.suitebuilder.TestMethod.instantiateTest(TestMethod.java:87)
at android.test.suitebuilder.TestMethod.createTest(TestMethod.java:73)
at android.test.suitebuilder.TestSuiteBuilder.addTest(TestSuiteBuilder.java:262)
at android.test.suitebuilder.TestSuiteBuilder.build(TestSuiteBuilder.java:184)
at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:379)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4316)
at android.app.ActivityThread.access$1400(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1457)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4998)
at java.lang.reflect.Method.invokeNative(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError: com.example.android_listview.MainActivity
at com.example.android_listview.test.android_listview_test.<init>(android_listview_test.java:13)
... 18 more

请尽量让自己的答案能够对别人有帮助

2个答案

默认排序 按投票排序
0

 I truly love how it is easy on my eyes and the data are well written.   free online cribbage

0
Caused by: java.lang.NoClassDefFoundError: com.example.android_listview.MainActivity
at com.example.android_listview.test.android_listview_test.<init>(android_listview_test.java:13).

这个信息已经说明得很清楚了,就是在com.example.android_listview.test.android_listview_test.<init>(android_listview_test.java:13).中没有找到 com.example.android_listview.MainActivity这个类。

仔细看了一下,你是在两个项目中运行测试。你应该把两个项目合并成一个。