This section describes the test impact analysis workflow for Jtest desktop users. For information about test impact analysis from the command line, see Testing and Analysis with Maven and Testing and Analysis with Gradle.
In this section:
Jtest's test impact analysis helps you optimize your testing efforts by automatically detecting test cases affected by locally modified code. This allows you to identify and re-run only the tests that are affected by your change.
Jtest relies on coverage data to create a correlation between a code section and the tests that cover that section. For this reason, you need to ensure that coverage data is imported into your IDE before running your tests.
Test impact analysis is available for projects that are stored in a version control system integrated with your IDE.
1 Requires additional dependencies; see Known Limitations.
Before running tests, you need to ensure that coverage data related to the source code you modify is available in the Coverage View in your IDE. To achieve this, you need to integrate Jtest into your unit test execution to collect the coverage data in an XML file or report it to DTP, and then import the data to your IDE.
Information about correlations between tests and code persists between restarts of the IDE–even if the Coverage view does not display any coverage data after a restart. You can refresh correlations by re-importing coverage from a file or DTP to your IDE.
Re-import coverage data for the most recent test run on a regular basis to ensure that correlations are up to date with source code and tests in your version control system. |
The coverage.xml
file is generated when you run unit tests with your build tool (Maven, Ant, or Gradle) integrated with Jtest on your CI server. You can choose the option to import the coverage data from the file if all your unit tests are executed in a single test run.
Configure your unit test execution job to collect coverage data with Maven, Gradle, or Ant. When the job runs, coverage for executed tests will be saved in a coverage.xml
file in the job location on the server. Configure your job to save the file in a location from which it can be easily downloaded.
You can choose the option to import coverage data from DTP if there are multiple test runs you want to collect coverage for.
You can monitor and re-run tests impacted by your local code changes in the Impacted Unit Tests view. To open the view, choose Parasoft> Show View> Impacted Unit Tests in your IDE menu bar.
Jtest automatically monitors all open projects in the workspace. By default, the view displays in real time which tests are affected by your current code modifications–every time you make a code change that impacts a test, the view is refreshed to display that test. To switch off automatic detection of affected tests, disable the Auto detect impacted tests option in the view's menu.
If the option is disabled, you need to manually refresh the view by clicking the Refresh button.
You can right-click a detected test and choose Go to to view the test code in the editor:
In addition, the Impacted Unit Tests view displays:
To run all impacted tests that are displayed in the view, click the Run all tests button in the view's menu.
To run a subset of impacted tests, select the project, package, class, and/or method node(s) to analyze and click Run selected tests in the view menu.
Alternatively, you can right-click the selection and choose Run selected tests.
Tests executed from the Impacted Unit Tests view will not update your coverage data. To view updated coverage results, run your tests from the Unit Test Assistant view or with the Jtest test configuration (see Executing and Collecting Coverage for JUnit Tests). |
While analyzing resources, Jtest creates two .java classes in the default package of your project that are used for storing information about affected tests and running the selected test methods. Do not commit these files to your source control system. For your convenience, you may consider adding them to the .gitignore file (in Git) or setting the svn:ignore property on all projects (in SVN).