This page outlines how the Launchable CLI interfaces with Maven.
This is a reference page. See Getting started, Sending data to Launchable, and Subsetting your test runs for more comprehensive usage guidelines.

Recording test results

Launchable supports test reports generated using Surefire, the default report plugin for Maven. See Maven Surefire Plugin – Introduction.
After running tests, point the CLI to your test report files to collect test results and train the model:
launchable record tests --build <BUILD NAME> maven './**/target/surefire-reports'
The invocation above relies on the CLI to expand GLOBs like **.
You might need to take extra steps to make sure that launchable record tests always runs even if the build fails. See Always record tests.

Subsetting your test runs

The high level flow for subsetting is:
  1. 1.
    Generate the full list of tests/test paths that would have run during a normal session
  2. 2.
    Pass that list to launchable subset with an optimization target for the subset
  3. 3.
    launchable subset will get a subset from the Launchable platform and output that list to a text file
  4. 4.
    Pass the text file into your test runner to run only those tests
To retrieve a subset of tests, first create a list of all the tests you would normally run using mvn test-compile. If you use any extra Maven options (such as -Dsurefire.includesFile, etc.), make sure to include them here so that the correct list of tests that would have run is generated:
mvn test-compile
This process generates a file you can pass into launchable subset. This file is normally located at target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst as shown below.
launchable subset \
--build <BUILD NAME> \
--confidence <TARGET> \
--test-compile-created-file <(find . -path '*/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst' -exec cat {} \;)
> launchable-subset.txt
  • The --build should use the same <BUILD NAME> value that you used before in launchable record build.
  • The --confidence option should be a percentage; we suggest 90% to start. You can also use --time or --target; see Subsetting your test runs for more info.
The launchable subset command outputs a file called launchable-subset.txt that you can pass into Maven to run Launchable's selected subset. How you do that depends on what test framework you use.

Maven + JUnit

mvn test -Dsurefire.includesFile=launchable-subset.txt
If your build is already depending on surefire.includesFile, or <includes>/<includesFile>, those and our subset will collide and will not work as expected. Contact us to resolve this problem.

Maven + TestNG

Modify your pom.xml so that it includes Launchable TestNG integration as a test scope dependency:
Pass the location of launchable-subset.txt as an environment variable. The abovementioned module will process this:
export LAUNCHABLE_SUBSET_FILE_PATH=$PWD/launchable-subset.txt

Maven + JUnit & TestNG

If your multi-module project mixes JUnit and TestNG in different modules, follow "Maven + JUnit" guide above. The caveat is that modules using testng.xml to specify the tests to run will not work correctly because testng.xml and surefire.includesFile interferes.
Last modified 10d ago