当前位置:操作系统 > 安卓/Android >>

android学习笔记转--junit.framework.AssertionFailedError: No tests found in错误解决办法

package cn.hxyh.cal.test;

import junit.framework.TestCase;
import cn.hxyh.cal.dao.CaculatorDAO;
import cn.hxyh.cal.factory.CaculatorFactory;

public class TestCaculator extends TestCase {

 public void TestAdd() {
  CaculatorDAO ca = CaculatorFactory.getCaculatorDAO();
  double result = ca.Add(3.5, 6.5);
  assertEquals(10, result, 0);
 }

}
---------------------------------------------------------------------------------------------------------------

junit.framework.AssertionFailedError: No tests found in cn.hxyh.cal.test.TestCaculator
 at junit.framework.Assert.fail(Assert.java:47)
 at junit.framework.TestSuite$1.runTest(TestSuite.java:97)
 at junit.framework.TestCase.runBare(TestCase.java:134)
 at junit.framework.TestResult$1.protect(TestResult.java:110)
 at junit.framework.TestResult.runProtected(TestResult.java:128)
 at junit.framework.TestResult.run(TestResult.java:113)
 at junit.framework.TestCase.run(TestCase.java:124)
 at junit.framework.TestSuite.runTest(TestSuite.java:232)
 at junit.framework.TestSuite.run(TestSuite.java:227)
 at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

 

-----------------------------------------------------------------------------------------------------------------

解决办法:www.zzzyk.com

将大写的 TestAdd() 修改成 testAdd()即可,若是方法名仅为Add,请在方法名前加上test。

 

摘自 奔跑的蜗牛
补充:移动开发 , Android ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,