2011-03-29 110 views
3

现在我正在完成教程,我在testApplication中发现了这种类型的错误。 我该怎么办? 这是简单的HeloAndroidTest应用程序。测试android应用程序错误

错误是你可以分享你HelloAndroidTest.java文件

java.lang.RuntimeException: Exception during suite construction 
at android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests.testSuiteConstructionFailed(TestSuiteBuilder.java:239) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169) 
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154) 
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529) 
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447) 
Caused by: java.lang.reflect.InvocationTargetException 
at java.lang.reflect.Constructor.constructNative(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:415) 
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:263) 
at android.test.suitebuilder.TestSuiteBuilder.build(TestSuiteBuilder.java:185) 
at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:373) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3210) 
at android.app.ActivityThread.access$2200(ActivityThread.java:117) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:966) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:123) 
at android.app.ActivityThread.main(ActivityThread.java:3647) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: java.lang.NoClassDefFoundError: com.example.helloandroid.HelloAndroid 
at com.example.helloandroid.test.HelloAndroidTest.<init>(HelloAndroidTest.java:13) 
... 18 more 
+0

Yikes !!!一次做一种语言,而不是三种! – pmg 2011-03-29 08:47:14

回答

0

?也许你忘了将Activity添加到Manifest.xml文件中,或者使用错误的布局。

+0

http://developer.android.com/resources/tutorials/testing/helloandroid_test.html – 2011-03-29 09:33:17

+0

错误是在行“super(”com.example.helloandroid“,HelloAndroid.class);”,所以有两种可能原因:1)HelloAndroid.class类名称错误或2)com.example.helloadroid错误引用。请检查它。 – 2011-03-29 09:54:58

+0

谢谢Mr.Anton Derevyanko – 2011-03-29 10:20:40

3

你好,未来!

super("com.example.helloandroid", HelloAndroid.class) 

已弃用。你需要在你的测试中没有ARG构造器,在以超级正是如此传递的活动:

public MyTest() { 
     super(MyActivity.class); 
    } 

也就是说这个错误的原因和治疗方法。