The jtest task should be applied and executed only for the root project. You do not need to build a project before running analysis, but we recommend compiling multi-module projects beforehand  by adding the build or assemble task to your command line, for example. Doing so enables Jtest to use artifacts from the local repository, reducing the amount of time necessary to test and analyze code.

Before you run analysis or collect coverage information with Gradle, ensure that the Jtest license is properly configured (see Setting the License).

Running Static Analysis

To perform static analysis on your code:

  1. Ensure that the Jtest Plugin for Gradle is set up (see Configuring the Jtest Plugin for Gradle).
  2. Execute the jtest task. Your command line may resemble the following:

    gradle jtest -I PATH/TO/JTEST/integration/gradle/init.gradle

    The Jtest Plugin for Gradle will collect the necessary build data in the .json file, and analyze your code depending on the test configuration you provided.

  3. Review the analysis results (see Reviewing Results).

Executing Unit Tests

You can include unit test results in the Jtest report by running your tests with the jtest task, and the dedicated Unit Tests built-in test configuration:

  1. Ensure that the Jtest Plugin for Gradle is set up (Configuring the Jtest Plugin for Gradle).
  2. Execute Gradle tasks in the following order:
    - the test (or build) task to ensure that unit tests are executed
    - the jtest task
      Your command line may resemble the following:

    gradle clean test jtest -Djtest.config="builtin://Unit Tests"

Collecting Coverage for Unit Tests

You can collect coverage information during execution of unit tests by your tests with the jtest and jtest-agent tasks, and the dedicated Unit Tests built-in test configuration:

  1. Ensure that the Jtest Plugin for Gradle is set up (Configuring the Jtest Plugin for Gradle).
  2. Execute Gradle tasks in the following order:
    - the jtest-agent task
    - the test (or build) task to ensure that unit tests are executed
    - the jtest task
      Your command line may resemble the following:

    gradle clean jtest-agent test jtest -Djtest.config="builtin://Unit Tests"

(info) We recommend using the jtest-agent task for collecting coverage. Offline instrumentation with the jtest-instument task is deprecated.

Collecting Application Coverage

Jtest's coverage agent allows you to collect coverage data during manual or automated tests performed on a running application. See Application Coverage for information about collecting application coverage with Jtest.

  • No labels