I love working with intelliJ for Java development. It allows me to use Visual studio key bindings, vim emulation, font ligatures and other powerful features that Visual studio offers, and besides all, it's much more affordable and viable replacement for all other slow development environments out there when it comes to Java Development.
I run the unittests from inside the IntelliJ environment and they seem to run quiet well without issues most of the times until i came across this error.
java.lang.Exception: No tests found matching Method TestMethod(com.mycompany.MyTestClass) from org.junit.internal.requests.ClassRequest@6ed3ccb2 at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:40) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:96) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:253) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
The only thing i did before this error is that i changed the name of the Test Method. But does it impact ? Yes, it does. To verify this goto IntelliJ Editor -> Run -> Run/Debug Configurations windows. You should see an error as follows
To get rid of the error, delete that entry for the test and start debugging the test again. A run configuration entry for the new test method will be created automatically by IntelliJ and things should work as normal.
The reason for the failure ofcourse is that, the IntelliJ IDE uses the type information to create run configurations and store them, this type information is mainy needed to pass it to the junit runner to filter the list of tests to be ran when a corresponding test run session is launched. This is too sophisticated as well as tricky to handle. Further if you would like to investigate, Open the console windows in Intellij and see the invocation command line when you run the test. It should have passed the filter (to run just your test method, or the context from which the test is ran). Have a good time unit testing your code.