java.lang.exception没有可运行的方法junit [英] java.lang.exception no runnable methods junit

查看:284
本文介绍了java.lang.exception没有可运行的方法junit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个套件,里面我添加了测试类。
我正在使用surefire来运行我的JUnits。
我的测试类以测试结束,方法有@test注释。



如何解决这个问题?

解决方案

对于这个不完整的问题,这里提供了各种建议(对于那些不幸到达这里可以通过google找到这个常见问题的答案):




  • 如果使用Junit4.x,只需使用注释(@Test);不要创建测试套件:请参阅此问题详细信息。


  • 原始问题表示@Test注释正在使用,这应该可以防止错误。但是如果先前有其他错误发生,仍然可以发生,并且junit可以隐藏此消息的原始问题。例如,看看Spring配置是否存在问题(未设置@Required属性),配置错误的mock对象等。


  • 以避免其他可能产生的其他常见问题这个错误(比如运行类后缀* Test,不要使用@Test方法),尝试更新到surefire插件2.7(目前为@ 2.8.1)和junit 4.7+(目前@ 4.8.1)以避免此问题(我使用maven3,btw;或许在mvn测试之前做一个mvn clean才能安全)


  • 长镜头:升级至少蚂蚁1.7+(目前1.8+)避免junit 4 测试套件问题



I have a suite, inside which I have added the test class. I am using surefire to run my JUnits. My test class ends with test and the methods has @test annotations to it.

How can this problem be resolved?

解决方案

Here are various suggestions for this incomplete question (for those unfortunate enough to be brought here by google looking for an answer to this common issue):

  • if using Junit4.x, just use annotations (@Test); don't create a test suite: see this question for details.

  • original question said "@Test" annotation is being used, which should prevent the error. But it can still happen if there are other errors that happen earlier, and junit can hide the original problem with this message. E.g., see if there are problems with Spring configuration (unset @Required attributes), misconfigured mock objects, etc.

  • to avoid other frequent issues that also may generate this error (such as running classes suffixed by "*Test" that do not have any @Test methods), try updating to the surefire plugin 2.7 (currently @2.8.1) and junit 4.7+ (currently @4.8.1) to avoid this issue (i'm using maven3, btw; perhaps do a "mvn clean" before "mvn test" to be safe)

  • long shot: upgrade to at least ant 1.7+ (currently 1.8+) to avoid junit 4 test suite issues

这篇关于java.lang.exception没有可运行的方法junit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆