IntroductionYou can extend the capabilities of the Jtest Plugin for Maven with test impact analysis. It allows you to you to identify and re-run only the tests that are affected by your changes, eliminating the time and effort required to execute a large number of unaffected tests. To perform test impact analysis of your project, you need to:
Prerequisites
|
<build>
<plugins>
<plugin>
<groupId>com.parasoft.jtest.tia</groupId>
<artifactId>tia-maven-plugin</artifactId>
<version>2025.2.0</version>
</plugin>
</plugins>
</build> |
You can customize test impact analysis of your project in the POM file or in the command line by configuring tia-maven-plugin. At minimum, you must provide the paths to the following files that are generated by Jtest during execution:
coverage.xml
report.xml
You must provide an absolute path to the coverage.xml file if one or more tests are in a different project than the tested source code to to ensure that all affected tests are re-run.
See Jtest Goals Reference for Maven for the complete list of available options.
If you configure the plugin in the POM file, you can add the tia-maven-plugin properties to:
plugin declaration
<plugin>
<groupId>com.parasoft.jtest.tia</groupId>
<artifactId>tia-maven-plugin</artifactId>
<version>2025.2.0</version>
<configuration>
<referenceCoverageFile>target/jtest/coverage.xml</referenceCoverageFile>
<referenceReportFile>target/jtest/report.xml</referenceReportFile>
<runFailedTests>false</runFailedTests>
<runModifiedTests>true</runModifiedTests>
<jtestHome>${jtest.home}</jtestHome>
<settings>jtestcli.properties</settings>
</configuration>
</plugin> |
plugin execution
<plugin>
<groupId>com.parasoft.jtest.tia</groupId>
<artifactId>tia-maven-plugin</artifactId>
<version>2025.2.0</version>
<executions>
<execution>
<goals>
<goal>affected-tests</goal>
</goals>
<configuration>
<referenceCoverageFile>target/jtest/coverage.xml</referenceCoverageFile>
<referenceReportFile>target/jtest/report.xml</referenceReportFile>
<runFailedTests>false</runFailedTests>
<runModifiedTests>true</runModifiedTests>
<jtestHome>${jtest.home}</jtestHome>
<settings>jtestcli.properties</settings>
</configuration>
</execution>
</executions>
</plugin> |
Maven properties
<properties>
<jtest.referenceCoverageFile>target/jtest/coverage.xml</jtest.referenceCoverageFile>
<jtest.referenceReportFile>target/jtest/report.xml</jtest.referenceReportFile>
<jtest.runFailedTests>false</jtest.runFailedTests>
<jtest.runModifiedTests>true</jtest.runModifiedTests>
<jtest.home>${env.JTEST_HOME}</jtest.home>
<jtest.settings>jtestcli.properties</jtest.settings>
</properties> |
If you customize test impact analysis in the command line, pass the tia-maven-plugin properties with the -D switch. The properties must include the "jtest" prefix (see Jtest Goals Reference for Maven for details). Your command line may resemble the following:
mvn tia:affected-tests test -Djtest.referenceCoverageFile=target/jtest/coverage.xml -Djtest.referenceReportFile=target/jtest/report.xml -Djtest.runFailedTests=false -Djtest.runModifiedTests=true -Djtest.home=$JTEST_HOME -Djtest.settings=jtestcli.properties |
affected-tests GoalYou can configure execution of the affected-tests goal from the command line or by configuring the goal in the POM file.
When tia-maven-plugin is included in the Maven build file (see Integrating with the Test Impact Analysis Plugin), you can execute the tia:affected-tests goal from the command line. Ensure it is executed before the test goal:
mvn tia:affected-tests test |
You can configure execution of the affected-tests goal in the build plugins or in the the build plugins of the profile.
If you include the affected-tests goal in the build plugins:
<build>
<plugins>
<plugin>
<groupId>com.parasoft.jtest.tia</groupId>
<artifactId>tia-maven-plugin</artifactId>
<version>2025.2.0</version>
<executions>
<execution>
<goals>
<goal>affected-tests</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build> |
it will be automatically executed with the Maven test goal:
mvn test |
If you include the affected-tests goal in the build plugins of the profile:
<profile>
<id>tia</id>
<build>
<plugins>
<plugin>
<groupId>com.parasoft.jtest.tia</groupId>
<artifactId>tia-maven-plugin</artifactId>
<version>2025.2.0</version>
<executions>
<execution>
<goals>
<goal>affected-tests</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile> |
you must execute the Maven test goal using the profile:
mvn test -P tia |
Test impact analysis re-runs the entire test suite when at least one test included in that test suit is affected by code changes. Note that this may result in re-running some tests that are not affected if they are included in the same test suite as affected tests.
By default, the Maven surefire plugin is unable to re-run nested tests. To ensure that nested tests are re-executed when you run test impact analysis with Maven, add the <include></include> and <exclude></exclude> elements to the Maven surefire plugin configuration, for example:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<includes>
<include></include>
</includes>
<excludes>
<exclude></exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build> |
Test impact analysis relies on Surefire's default include/exclude mechanism, as well as on custom includes and excludes configured in the current POM file. In rare cases, test impact analysis may be unable to recognize the include or exclude pattern. This may result in failing to re-run affected tests that match the pattern and/or re-running tests that are not affected by code changes.
As a workaround, you can specify the file pattern in the command line with the -Dparasoft.testFilter option. Your command line may resemble the following:
mvn tia:affected-tests test -Djtest.referenceCoverageFile=target/jtest/coverage.xml -Djtest.referenceReportFile=target/jtest/report.xml -Djtest.settings=jtestcli.properties -Djtest.testFilter="**/*Test.java, !**/ProblemTest.java" |
Note that Surefire's built-in -Dtest option for executing individual tests is not supported for test impact analysis with Jtest. Using the -Dtest option results in overriding the includes and excludes configured for test impact analysis in the POM file and in the command line.