java.lang.exception no runnable methods junit

前端 未结 2 464
我在风中等你
我在风中等你 2021-01-12 05:45

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.

相关标签:
2条回答
  • 2021-01-12 06:11

    You are using the correct version of JUnit at least 4.X to be able to use annotations for that? (Maven?)

    0 讨论(0)
  • 2021-01-12 06:29

    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

    0 讨论(0)
提交回复
热议问题