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.

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.

Prerequistes

Test impact analysis is available for projects that are stored in a version control system integrated with your IDE.

  • Jtest 10.4.0 or later
  • Eclipse or IntelliJ IDE (see Prerequisites for supported versions)
  • SVN or Git
  • JUnit 4

Importing Coverage

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. Collecting coverage data for each run of your unit test suite and importing the data for the most recent test run allows you to ensure that the information in your IDE is up-to-date.

Importing From a File

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 import the coverage data from the file if all your unit tests are executed in a single test run.

  1. Integrate Jtest with your build system (see Integrating with Build Systems).
  2. 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.
    (tick) Configure your job to save the file in a location from which it can be easily downloaded.

  3. Import the coverage data from the file to your IDE using the Import from Local File or URL option (see Importing Coverage). You can download the file from your build server and then specify the path to the local file, or specify the URL to the file stored on your build server.

Importing from DTP

You can import coverage data from DTP if there are multiple test runs you want to collect coverage for.

  1. Enable connection with DTP (see Connecting to DTP).
  2. Integrate Jtest with Maven, Ant, or Gradle (see Integrating with Build Systems).
  3. Ensure Jtest is configured to send coverage data to DTP (see Sending Coverage Information to DTP).
  4. Configure a unit test execution job(s). When the job runs, coverage data for executed tests will be sent to DTP and merged with data from previous runs.
  5. Import the coverage data from the file to your IDE using the Import from DTP option (see Importing Coverage).

Monitoring and Running Impacted Tests

You can monitor and re-run the affected tests in the Impacted Unit Tests view. To open the view, choose ParasoftShow View> Impacted Unit Tests in your IDE menu bar.

Monitoring Impacted Tests

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.

In addition, the Impacted Unit Tests view displays:

  • the number of projects that contain impacted tests
  • the total number of affected test methods and test classes
  • the current status of the tests  (Passed/ Failed/ Not run)

Running Impacted Tests

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.

To run all impacted tests that are displayed in the view, click the Run all tests button in the view's menu.


Updating coverage information

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).

(info) 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).

  • No labels