Introduction

You 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:

  1. Add the test impact analysis plugin (tia-maven-plugin) shipped with Jtest to your Maven build.
  2. Configure the plugin.
  3. Execute the affected-tests goal.

Prerequisites

  • Jtest 10.4.1 or higher
  • Apache Maven 3.3.9 or higher (versions 3.3.1 and 3.3.3 are not supported)
  • Surefire 2.19.1 or higher
  • JUnit 4 or 5

(info) The Jtest Plugin for Maven must be configured to ensure access to the Maven repository shipped with Jtest; see Initial Setup.

(tick) Test impact analysis may require additional memory. We recommend increasing the memory allocated to the Maven build.

Integrating with the Test Impact Analysis Plugin

You can integrate with the test impact analysis plugin by adding tia-maven-plugin to the list of plugins in the POM file:

<build>
    <plugins>
        <plugin>
            <groupId>com.parasoft.jtest.tia</groupId>
            <artifactId>tia-maven-plugin</artifactId>
            <version>2025.2.0</version>
        </plugin>
    </plugins>
</build>

Configuring the Plugin

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.

In the POM file

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>

In the Command Line

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

Configuring and Executing the affected-tests Goal

You can configure execution of the affected-tests goal from the command line or by configuring the goal in the POM file.

In the Command Line

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

In the POM file

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

Re-executing Test Suites

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.

Re-executing Nested 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>

Manually Filtering Tests to Re-run

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.