This section provides information about the Jtest tasks for Gradle and their parameters. The following tasks are available:
jtest
The Gradle task to execute Jtest.
Attributes
Name | Accepted values / data type | Description | Required |
---|---|---|---|
compilation | Compilation | A description of manual configuration data (see Manual Customization of Compilation Data) | No |
compilations | List | A list of descriptions of manual configuration data (see Manual Customization of Compilation Data) | No |
dataUpdate | String | Allows you to manually update compilation data collected from the build. User property is: | No |
config | String | The name of a built-in, DTP, or user-defined test configuration. User property is: | No |
exclude | String | Specifies a subset of files or packages from the selected resources that will be excluded from analysis. You can provide the qualified names or use Ant glob patterns to match more filenames. User property is: | No |
excludes | List | A list of exclude parameters. User property is: | No |
excludeTestSources | true | false | Excludes test source code from analysis. Default value is: User property is: | No |
fail | true | false | Fails the build if any violation is reported. User property is: | No |
home | Path | Specifies the Jtest installation directory. If not defined, the Jtest location specified on PATH will be used. User property is: | Recommended |
ignoredIds | List | A list of ignored compilation IDs. User property is: | No |
include | String | Specifies a subset of files or packages form the selected resources that will be included during analysis. User property is: | No |
includes | List | A list of include parameters. User property is: | No |
publish | true | false | Enables reporting results of local analysis to the DTP server. User property is: | No |
report | Path | Specifies the directory where the report will be created. User property is: | No |
resource | String | Specifies the input scope for analysis. If no resources are specified, Jtest will analyze resources from every built project. User property is: | No |
resources | List | A list of resource parameters. User property is: | No |
settings | Path | An absolute or relative path to the *properties file that includes custom configuration settings. User property is: jtest.settings | No |
settingsList | List | A list of settings parameters. User property is: | No |
showDetails | true | false | Displays detailed progress information. User property is: jtest.showdetails | No |
showSettings | true | false | Prints the current settings and customizations along with the information where each of them is configured (e.g. in the jtest.properties file). User property is: | No |
projectNameTemplate | String | The project name template. This parameter allows you to configure the pattern with the options [group], [name], [version], [path], and [basedir]. User property is: | No |
skip | true | false | Allows you to skip the Jtest execution phase. If set to User property is: | No |
Parameter Details
config
The name of a test configuration. The following configuration types are supported:
- built-in test configurations, for example
"builtin://Recommended Rules"
- dtp test configurations, for example
"dtp://New Config"
- user-defined test configurations, for example
"user://Your Config"
User-defined test configurations should be stored in the [INSTALL_DIR]/configs/user directory as *.properties files.
dataUpdate
Allows you to manually update compilation data collected from the build.
- Supported actions: prepend, append, and set.
- Supported data types: classpath, bootpath, sourcepath, resourcepath, binarypath, sourcecode (set only) and encoding (set only)
- Scope: all collected projects data will be updated
See Manual Customization of Compilation Data and Compilation Data Model for more information.
exclude
Specifies a subset of files or packages from the selected resources that will be excluded from analysis. You can provide the qualified names. You can use glob patterns to match more filenames.
Example 1: The following pattern excludes all files from com.parasoft package and its sub-packages: /com/parasoft/**
Example 2: The following pattern excludes all files from the package com.parasoft.jtest, but NOT from its sub-packages: /com/parasoft/jtest/*
Example 3: The following pattern excludes all files from the given directory and all subdirectories: path:/home/user/project/src/test/java/**
include
Specifies a subset of files or packages form the selected resources that will be included during analysis. You can use glob patterns to match more filenames.
Example 1: The following pattern includes all files from com.parasoft package and its sub-packages: /com/parasoft/**
Example 2: The following pattern includes all files from the package com.parasoft.jtest, but NOT from its sub-packages: /com/parasoft/jtest/*
Example 3: The following pattern includes all files from the given directory and all subdirectories: path:/home/user/project/src/test/java/**
resource
Specifies the input scope for analysis. If no resources are specified, Jtest will analyze resources from every built project.
Use the following pattern to specify the paths: ${ProjectName}/my/src/dir/my/package/file.java". You can use the following wildcards:
- ? - matches one character
- * - matches zero or more characters, except the path separator (the / character)
- ** - matches entire paths, including the path separator (the / character)
settings
An absolute or relative path to the *properties file that includes custom configuration settings.
projectNameTemplate
The project name template. By default, the following pattern is used to create project names in json: "group:name". This parameter allows you to configure the pattern with the options [group], [name], [version], [path], and [basedir], for example, to make a project name compatible with the project name in Eclipse.
Parameter Type Details
The following examples assume that the Jtest Plugin for Gradle has been properly configured and applied in the Gradle build script; see Configuring the Jtest Plugin for Gradle.
Compilation Type
- Attribute: Compilation
- A nested object
jtest { home = "path/to/jtest" compilation { id = "main" override = true } }
List Type
- Attribute: resources
- Specifies the list of resource patterns to match against resources that are collected during the build.
jtest { home = "path/to/jtest" resources = [ "**.java", "myGradleProjectName/src/com/mycompany/models/**/*.properties" ] }
String Type
- Attribute: Exclude
- Specifies a subset of files or packages from the selected resources that will be excluded from analysis.
jtest { home = "path/to/jtest" exclude = "com/mycompany/models/**/NotInteresting*.properties" }
See Compilation Data Model for more information.
jtest-agent
The Gradle task to collect coverage with Jtest.
Parameters
Name | Accepted values / data type | Description | Required |
---|---|---|---|
home | Path | Jtest installation directory. User property is: | Yes |
enableJacoco | true | false | Allows you to enable or disable collecting line coverage with the Jacoco engine. Default value is: User property is: | No |
skip | true | false | Allows you to skip the Jtest tasks. Default value is: User property is: | No |
runtimeDataLocation | Path | The path to the file where coverage runtime data will be stored. User property is: | No |
metadataLocation | Path | The path to the file where coverage metadata data will be stored. User property is: | No |
coverage | A set of parameters that allow you to configure collecting coverage.
| No |
Parameter Details
coverage
The default is:
jtest { /* other parameters */ coverage { skip = false includes = [ 'package/**' ] excludes = [ ] testIncludes = [ 'package/Test.class' ] testExcludes = [ ] } }
runtimeDataLocation
The default is: ${basedir}/parasoft/jtest-instrument/runtimedata.data
metadataLocation
The default is: ${basedir}/parasoft/jtest-instrument/metadata.data
jtest-monitor
This task scans the build to generate settings for the Jtest Java Agent, and creates a monitor package in location specified with the monitorLocation parameter.
The monitor package contains the following:
- static_coverage.xml - the file that contains static coverage information
- agent.jar - the Jtest Java coverage agent jar archive
- agent.properties - the agent settings file that contains scope parameters generated during the build process and other attributes
- agent.sh/agent.bat - the script that generates the Jtest Java agent VM arguments necessary to monitor the application
- opentelemetry-javaagent.jar and jtest-otel-ext.jar - files used in multiuser coverage mode: the original OpenTelemetry Java agent and the Jtest extension for it. This extension collects data necessary to assign collected coverage to a particular user. The files are copied from the
<INSTALL_DIR>/integration/coverage
directory.
Parameters
Name | Accepted values / data type | Decription | Required |
---|---|---|---|
agentServerEnabled | true | false | A switch that allows you to enable the Agent server. User property is: jtest.agentServerEnabled | No |
autostartAgent | true | false | A switch to automatically enable collecting coverage. User property is: | No |
compilation | Compilation | A description of manual configuration data (see Manual Customization of Compilation Data) | No |
coverage | A set of parameters that allow you to configure collecting coverage.
| ||
enableJacoco | true | false | Allows you to enable or disable collecting line coverage with the Jacoco engine. Default value is: User property is: | No |
exclude | String | Specifies a subset of files or packages from the selected resources that will be excluded from analysis. You can provide the qualified names or use Ant glob patterns to match more filenames. User property is: | No |
excludes | List | A list of exclude parameters. User property is: | No |
home | Path | Jtest installation directory. User property is: | Recommended |
ignoredIds | List | A list of ignored compilation IDs. User property is: | No |
include | String | Specifies a subset of files or packages form the selected resources that will be included during analysis. User property is: | No |
includes | List | A list of include parameters. User property is: | No |
monitorLocation | Path | The path to the location where the monitor package will be created. User property is: jtest.monitorLocation | No |
publish | true | false | Enables reporting results of local analysis to the DTP server. User property is: | No |
report | Path | Specifies the directory where the report will be created. User property is: | No |
resource | String | Specifies the input scope for analysis. If no resources are specified, Jtest will analyze resources from every built project. User property is: | No |
resources | List | A list of resource parameters. User property is: | No |
settings | Path | An absolute or relative path to the *properties file that includes custom configuration settings. User property is: jtest.settings | No |
settingsList | List | A list of settings parameters. User property is: | No |
showDetails | true | false | Displays detailed progress information. User property is: jtest.showdetails | No |
showSettings | true | false | Prints the current settings and customizations along with the information where each of them is configured (e.g. in the jtest.properties file). User property is: | No |
projectNameTemplate | String | The project name template. This parameter allows you to configure the pattern with the options [group], [name], [version], [path], and [basedir]. User property is: | No |
skip | true | false | Allows you to skip the Jtest execution phase. If set to User property is: | No |
Parameter Details
exclude
Specifies a subset of files or packages from the selected resources that will be excluded from analysis. You can provide the qualified names. You can use glob patterns to match more filenames.
Example 1: The following pattern excludes all files from com.parasoft package and its sub-packages: /com/parasoft/**
Example 2: The following pattern excludes all files from the package com.parasoft.jtest, but NOT from its sub-packages: /com/parasoft/jtest/*
Example 3: The following pattern excludes all files from the given directory and all subdirectories: path:/home/user/project/src/test/java/**
include
Specifies a subset of files or packages form the selected resources that will be included during analysis. You can use glob patterns to match more filenames.
Example 1: The following pattern includes all files from com.parasoft package and its sub-packages: /com/parasoft/**
Example 2: The following pattern includes all files from the package com.parasoft.jtest, but NOT from its sub-packages: /com/parasoft/jtest/*
Example 3: The following pattern includes all files from the given directory and all subdirectories: path:/home/user/project/src/test/java/**
resource
Specifies the input scope for analysis. If no resources are specified, Jtest will analyze resources from every built project.
Use the following pattern to specify the paths: ${ProjectName}/my/src/dir/my/package/file.java". You can use the following wildcards:
- ? - matches one character
- * - matches zero or more characters, except the path separator (the / character)
- ** - matches entire paths, including the path separator (the / character)
settings
An absolute or relative path to the *properties file that includes custom configuration settings.
projectNameTemplate
The project name template. By default, the following pattern is used to create project names in json: "group:name". This parameter allows you to configure the pattern with the options [group], [name], [version], [path], and [basedir], for example, to make a project name compatible with the project name in Eclipse.
Parameter Type Details
The following examples assume that the Jtest Plugin for Gradle has been properly configured and applied in the Gradle build script; see Configuring the Jtest Plugin for Gradle.
Compilation Type
- Attribute: Compilation
- A nested object
jtest { home = "path/to/jtest" compilation { id = "main" override = true } }
List Type
- Attribute: resources
- Specifies the list of resource patterns to match against resources that are collected during the build.
jtest { home = "path/to/jtest" resources = [ "**.java", "myGradleProjectName/src/com/mycompany/models/**/*.properties" ] }
String Type
- Attribute: Exclude
- Specifies a subset of files or packages from the selected resources that will be excluded from analysis.
jtest { home = "path/to/jtest" exclude = "com/mycompany/models/**/NotInteresting*.properties" }
See Compilation Data Model for more information.
affectedTests
This goal is provided by the test impact analysis plugin shipped with Jtest and allows you to perform change-based testing of your project (see Test Impact Analysis).
Required Parameters
Name | User Property | Accepted values / data type | Description |
---|---|---|---|
referenceCoverageFile | jtest.referenceCoverageFile | Path | URL | The path to the coverage.xml file generated by Jtest during analysis. The file contains the coverage data collected during the run. If you specify a URL, the file is downloaded to the Jtest execution directory and removed every time Gradle is executed with the clean command. To change the default download location, configure the The default is: |
referenceReportFile | jtest.referenceReportFile | Path | URL | The path to the report.xml file generated by Jtest during analysis. The file contains information about unit tests executed during the run. If you specify a URL, the file is downloaded to the Jtest execution directory and removed every time Gradle is executed with the clean command. To change the default download location, configure the The default is: |
jtestHome | jtest.home | Path | The path to the Jtest installation directory. It is not required if the Jtest installatation directory has already been configured with the Maven settings or the JTEST_HOME environment variable. |
Optional Parameters
Name | User Property | Accepted values / data type | Description |
---|---|---|---|
referenceStore | jtest.referenceStore | Path | The path to the cache directory where the reference files are stored when downloaded from URLs specified with the The cache files are used as a baseline for test impact analysis until they are removed from the specified directory. When removed, they are re-downloaded form the URLs. |
runFailedTests | jtest.runFailedTests | true | false | Enables including all failing tests form the previous run in the test run, even if they were not affected by the changes. The default is: |
runModifiedTests | jtest.runModifiedTests | true | false | Enables including new and modified tests (even if they were not affected by production code changes) in the test run. The default is: |
settings | jtest.settings | Path | The path to the .properties file that includes custom configuration settings. |
settingsList | jtest.settingsList | A list of The settings configured in the jtest.properties file located in the Jtest installation directory are automatically included. |