- Change your pom.xml to configure maven to use junit 4 not 3.8.1 by adding the maven-surefire-junit4 and deleting the junit dependency. Maven will automatically download all necessary dependencies, even the transitive ones and because surefire-junit4-2.3 depends on junit-4.0 this jar will also be downloaded.
So that's it with NetBeans and two of three possible ways how to run maven with Junit 4. No I'd like to show how to configure Maven and Eclipse (by the way: I use the new version of Eclipse ==> Codename: Europa). So here we go...
- First you have to install the M2 Eclipse Plugin: Have a look at my "Debugging Custom Maven Plugins"-How To. There you will find how to install the plugin in the IDE.
- Now you have to invoke maven's install-plugin by executing the command: mvn install. Maven will then download all necessary plugins e.g. junit-4.0.jar, etc.
- Now, I tried to run the test via M2 Eclipse Plugin but the build failed. Have a look at the output, you'll see the error-log and maybe it makes sense to you but I don't have any ideas why the tests fail. If you invoke the same command (mvn test) over the command-line everything works fine so it seems to me that the M2 Plugin is Buggy.
Maybe, if you have a solution you can post it, I'd be very thankful.
Have fun coding with maven and JUnit with your favourite IDE.