Jtest's change-based testing capabilities help 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 changes – saving the time and effort of executing a large number of unaffected tests for fear they might be broken.

Prerequistes

Change-based testing is available for projects that are stored in a version control system integrated with your IDE.

Currently, change-based testing is supported for JUnit 4 tests.

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

Running Tests

  1. Right-click a resource (a project, package, class, or method) in the Project Explorer and choose Unit Testing> Run tests impacted by local changes to display a list of unit tests that were affected by changes in the selected resource files. Alternatively, you can right-click a class in the editor and select Unit Testing> Run tests impacted by local changes from the context menu.


    You can monitor progress in the Progress View while Jtest is analyzing resources and identifying affected tests.


  2. Select a project, package, class, or test method. UTA will display the total number of selected unit test methods.
  3. Click Run to run the selected 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.

  • No labels