This page outlines how the Launchable CLI interfaces with Gradle+TestNG.
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> gradle ./build/test-results/test/
- By default, Gradle's report files are saved to
build/test-results/test/, but that might be different depending on how your Gradle project is configured.
- You can specify multiple directories if you do multi-project build.
- Alternatively, you can specify a glob pattern for directories or individual test report files (this pattern might already be specified in your pipeline script for easy copy-pasting), e.g.
First, you need to add a dependency declaration to
build.gradleso that the right subset of tests get executed when TestNG runs:
The high level flow for subsetting is:
- 1.Get the full list of test directories/tests/test paths and pass that to
launchable subsetwith an optimization target for the subset
launchable subsetwill get a subset from the Launchable platform and output that list to a text file
- 3.Pass the text file into your test runner to run only those tests
To retrieve a subset of tests, first list all the directories containing tests you would normally run (e.g.
project1/src/test/java) and pass that to
launchable subset \
--build <BUILD NAME> \
--confidence <TARGET> \
project2/src/test/java > launchable-subset.txt
--buildshould use the same
<BUILD NAME>value that you used before in
launchable record build.
This creates a file called
launchable-subset.txt. For Gradle, this file is formatted like:
You can pass this file into the Gradle launchable extension through an environment variable:
Note: The Gradle plugin for Android requires a different command, because the built-in
testtask does not support the