java Junit 测试中异常处理
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java Junit 测试中异常处理相关的知识,希望对你有一定的参考价值。
错误提示:
junit.framework.AssertionFailedError: No tests found in错误解决办法
用junit Test运行后,出现如下的错误:junit.framework.AssertionFailedError: No tests found in com.wichina.model.Test 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)
解决方法:
在测试办法前面加test,例如,如果方法名是getAll(),则改为testGetALl()。这样后就可以运行了
以上是关于java Junit 测试中异常处理的主要内容,如果未能解决你的问题,请参考以下文章
Java课程学习笔记 — JUnit accuracy/failure/stress test区别
使用Junit单元测试报错“No tests found matching Method test01(Test01) from ClassRequest@5387f9e0“