So today I had to figure out how to run integration tests with Maven2. (http://maven.apache.org/)
The Maven2 build approach to integration tests has some issues:
- No convention for separate source directory for IT tests.
- No default test runner for the integration-test phase.
Three solutions presented themselves for handling the IT (integration) tests.
- Use the failsafe plugin. (http://mojo.codehaus.org/failsafe-maven-plugin/) This uses naming conventions to build up a test suite. However, this approach can be broken since JUnit 4 allows test classes to use any name, thus providing unit tests and integration tests to get confused.
- Hack the maven script to force the test compilation and test running of a separate integration test source directory. This approach could take a long time to develop correctly, however, it’s a pay once and reuse type of solution. Could also be difficult to maintain unless you’re a Maven2 guru. (Ha, that rhymes)
- Separate the integration tests into a different project. This allows all the integration tests to be centrally located and run using the Maven conventional src/test/java directory. Tests can easy to copied over into a basic archetype with their own dependencies. Also this project can be independently executed on the CI. Should be simple to setup and follows the SRP. (Single Responsibility Principle)
The third option was the selected solution. If anyone else has faced this issue and has a different/better solution, please comment.
Advertisement

Cool
Comment by J — October 28, 2009 @ 11:47 am
Hi, Amazing! Not clear for me, how offen you updating your achesny.wordpress.com.
BernieR
Comment by BernieR — November 8, 2009 @ 2:13 pm