Junit单元测试问题 junit.framework.AssertionFailedError: Method "test" not found at android.test.AndroidTes

来源:互联网 发布:北大青鸟软件学校 编辑:程序博客网 时间:2024/05/21 09:19

在单元测试中出现了下面的问题:

junit.framework.AssertionFailedError: Method "testAdd" not found

at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:545)

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


源代码是

private void testAdd() {
System.out.println("测试单元框架");
}


错误原因:单元测试的时候方法不能私有化

解决方法:将private改成public

修改后年的代码是:

public  void testAdd() {
System.out.println("测试单元框架");
}


0 0