Search code examples
mavenmaven-failsafe-plugin

How to run maven failsafe without compiling first


I have a multi-module project with unit tests and integration tests. We're using Jenkins for our pipeline:

  1. build + unit tests
  2. deploy to staging
  3. integration tests against staging.

What I want to achieve is:

  • Step one - build + unit test + package + install
  • Step two - deploy already packaged artifacts
  • Step three - run integration tests (without building all over again)

Step three starts from a clean checkout, so there isn't even a target folder.

Edit - the integration test run inside a profile, so they don't run during the first build

What I want to achieve is to run the integration tests (step three) without compiling the code.

If I use mvn failsafe:integration-tests it says that there aren't any tests (obviously because it doesn't find any artifact).

When I add dependenciesToScan it says that it doesn't find the junit provider (groups/excludedGroups require TestNG, JUnit48+ or JUnit 5 on project test classpath).

Can someone help on how to implement running the tests when the jars are in the local repo, without compiling?


Solution

  • I did something similar several times. My standard solution is to put the system test suite in a separate module next to the actual artifact in the same repository.

    Steps one and two would happen only within the service module, while step three happens in the system-test module running mvn verify.