Maven2 introduces a build lifecycle with different phases as follows (the list is not complete):
- validate – validate the project is correct and all necessary information is available
- compile – compile the source code of the project
- test – test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed
- package – take the compiled code and package it in its distributable format, such as a JAR.
- integration-test – process and deploy the package if necessary into an environment where integration tests can be run
- verify – run any checks to verify the package is valid and meets quality criteria
- install – install the package into the local repository, for use as a dependency in other projects locally
- deploy – done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.
As you see, there are two different test phases: test and integration-test. Unfortunately maven2 does not provide two different sources directory for the different test contexts, making it quite difficult to organize and setup the test environment.
Chatting with users and developers at the maven irc channel (irc://irc.codehaus.org/#maven) and searching the net I found two different solutions to this particular problem.
The third solution presented in this article is a tricky usage of the surefire plugin configuration that is doing the best job for me (and other developers at Orientation in Objects).
Depending on your IDE, project layout and personal preferences you might prefer another solution than I have chosen for my projects.
Read the rest of this entry »