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.
Running Static Analysis
To perform static analysis on your code:
- Ensure that the Jtest Plugin for Gradle is set up (see Configuring the Jtest Plugin for Gradle).
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.
- 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:
- Ensure that the Jtest Plugin for Gradle is set up (Configuring the Jtest Plugin for Gradle).
Execute Gradle tasks in the following order:
- thetest
(orbuild
) 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:
- Ensure that the Jtest Plugin for Gradle is set up (Configuring the Jtest Plugin for Gradle).
Execute Gradle tasks in the following order:
- the jtest-agent task
- thetest
(orbuild
) 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"
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.