问题
I am moving from using only Intellij to manage my build system to Intellij/Maven. When I run my integration test "MapSimulationTest" with my own runner via @RunWith(KmlParameterizedRunner.class) Intellij correctly handles the situation, the directory specified by the system property "user.dir" is scanned for .kml files and each is tested.
The problem seems to be that Surefire ignores @RunWith, any suggestions?
Here is what the maven log shows...
------------------------------------------------------- T E S T S ------------------------------------------------------- Running com.tqicorp.guru.MapSimulationTest Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.061 sec
回答1:
I'm using surefire and @RunWith with the Spring test runner, and it is working fine with maven 2.2.1.
To track down the problem, you could try creating a simple Junit test using the @Test annotation, rather than the old style testXXX method. Run "mvn test" and see if your test is being executed. If it is, that will rule out any possibility of an old junit in your path. If it's not being executed, then run "mvn site", and search the dependencies report for junit, and check the version. It's amazing how easy unwanted versions can creep in!
回答2:
You may already be doing it, but this can happen if your maven dependency is using old junit version (3.x) instead of junit 4.x where these annotations are respected. Check your pom.xml to see if the right junit version is the articfact
回答3:
Try verifying you are using the latest version of the maven-surefire-plugin; I have been burned in the past by bugs with my surefire uasge until I relized these bugs had been fixed in a newer version of the plugin and I simply had to update.
回答4:
This might happen if you have TestNG dependency. Remove dependency and Maven will search for @org.junit.Test annotations in your classes, if TestNG dependency present then Maven search for @org.testng.annotations.Test annotation.
来源:https://stackoverflow.com/questions/2717902/runwith-causes-maven-to-ignore-my-test-running-with-my-own-runner