Wednesday, September 16, 2009

Maven Surefire for Integration Tests in JUnit

It is quite convenient to use maven-surefire-plugin to run tests using Maven. It enables generating reports in txt, XML as well as HTML. By default surefire tests are executed in the test phase of Maven build lifecycle. Therefore it enables to run unit tests, but not integration tests which should be executed after package phase.
It is just a matter of configuring the surefire plugin, in order to run integration tests. The configuration given below can be used to change the phase of the surefire plugin.

<!-- skip unit tests in the test phase, since it is required to run integration tests -->
In addition, we need to add the junit dependancy to the pom's dependancy list. This should be added in a manner that it resolves only for the testing.



The version may change depending on your requirements.

No comments:

Post a Comment