没有找到Class Def错误java Android活动测试

时间:2014-04-22 01:39:24

标签: java android testing android-activity

我正在尝试使用ActivityInstrumentationTestCase2进行Android活动测试。但我得到了以下错误。有人可以看一下吗?谢谢

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:190)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1584)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
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:4142)
at android.app.ActivityThread.access$1300(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError:         com.theice.android.icemobile.activities.positionkeeper.PositionKeeperActivity
at positionkeeper.PositionKeeperTest.<init>(PositionKeeperTest.java:14)

编辑:添加了代码

package positionkeeper;

import android.test.ActivityInstrumentationTestCase2;
import com.theice.android.icemobile.activities.positionkeeper.PositionKeeperActivity;

public class PositionKeeperTest extends ActivityInstrumentationTestCase2 <PositionKeeperActivity> {

public PositionKeeperTest() {
    super(PositionKeeperActivity.class);
}

public void testAmit () {
    assertTrue(1==1);
}
}

0 个答案:

没有答案