Getting started with Maven, Java, and Launchable

Announcing Predictive Tests Selection now available for Maven for faster, smarter test cycles.

Key Takeaways

  • Now available: Maven profile in the Launchable CLI!

  • Now you can use Launchable with Maven and Java to speed up you test cycles by choosing the most important tests to run with Predictive Test Selection.

  • Steps to subset tests with Maven.

Today, we are pleased to announce that we have added a Maven profile to the Launchable CLI. The Launchable CLI provides a simple, consistent interface between your testing tools and Launchable. The Maven profile makes it dead simple to use Launchable with Maven and Java. While it’s possible to use the CLI with almost any test runner, a profile makes integration straightforward. (We are constantly rolling out new profiles for test runners so if you need one that is not listed please let us know.)

Launch Fearlessly with Maven + Launchable

Launchable uses AI and machine learning to identify the right tests for a code change through a process called Predictive Test Selection. This is all done in real-time enabling you to run a subset of your larger test suite that dynamically adjusts based on the changes being tested. The resulting drop in test execution time lets you run tests earlier and more often, which can drastically reduce cycle times for software developers.

Subsetting tests with Maven

Basic integration with your CI pipeline involves three steps: recording buildssubsetting tests, and recording test results. The last step is essential because it is used to continuously train a machine learning model for your tests.

To tell Launchable that you are starting a new build, use this command:

launchable record build --name <BUILD NAME> --source .

Then to select a meaningful subset of tests, you need to tell Launchable where the tests are in your project so the CLI can find all the test classes:

launchable subset \
 --build <BUILD NAME> --target <TARGET> maven \
 ./**/src/test/java \
 > launchable-subset.txt

This command grabs all the test classes from your project and sends them to Launchable. Launchable then returns a subset of those classes to the CLI which then outputs them. We’re piping this into a file called launchable-subset.txt. This file will contain the subset of the most important tests to run for the changes in the build.

You can now tell Maven to run exactly those tests:

mvn test -Dsurefire.includeFiles=launchable-subset.txt

Then, after tests run, you run a similar command to collect test report XML files, parse them, and send the data to Launchable. (Note: the integration assumes you're using the Surefire plugin for Maven, which is the default.)

launchable record tests --build <BUILD NAME> maven \
./**/target/surefire-reports

As you can see, the CLI makes it easy to connect your existing tools with Launchable to intelligently subset your tests and save time.

Does any of this sound interesting? Reach out if you have thoughts or sign up for the beta to get access to Launchable before anyone else!

Seeking Your Expert Feedback on Our AI-Driven Solution

Quality a focus? Working with nightly, integration or UI tests?
Our AI can help.