2011-03-29 134 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); 
    } 

也就是說這個錯誤的原因和治療方法。