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.