Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.exception no runnable methods junit

Tags:

junit

eclipse

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?

like image 474
saurav Avatar asked May 12 '10 12:05

saurav


1 Answers

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

like image 87
michael Avatar answered Oct 20 '22 19:10

michael