carlspring carlspring - 1 year ago 100
Java Question

Where should the integration tests be stored when using the maven-failsafe-plugin?

Do I have to place my integration tests under

with the rest of my unit tests and just distinguish them by a pattern such as
, or can they be in
(as is the case when developing Maven plugins and using the

I'm asking this because, to me it looks not clean enough if both unit and integration tests are in the same place, (even if they were to be controlled via a Maven profile).

Answer Source

You are right that src/it is intended to be used for integrations test of plugins. This is mentioned in the Standard Directory Layout.

The maven-failsafe-plugin, by default, will look for your integration tests inside ${}, which is the same as the maven-surefire-plugin for unit tests. By default, this corresponds to src/test/java. The integration tests are made distinct by following a naming convention:


which is different than the naming convention for unit-tests:


So while they would reside in the same source folder (src/test/java), the difference in names clearly distinguishes them. Also, this is the default set-up so no extra configuration would be needed.

That said, you can have other options:

  • Place the integration tests inside a different source folder. This will require some configuration to make it work: you will need to use the build-helper-maven-plugin:add-test-source goal to add the custom folder as a test source folder.
  • Use a different module (if you have a multi-module Maven project) that would only contain the integration tests.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download