This topic explains how to build a Docker container image for running Jtest.

Requirements

  • Linux 64-bit
  • Docker
  • Jtest installation package for Linux 64-bit

Building a Container Image

Jtest  ships with support for building a Docker container image in the <INSTALL_DIR>/integration/docker directory. The directory contains an example Dockerfile and a jtestcli.properties file you can easily customize.

To build a Docker container image that includes Jtest:

  1. Copy the Jtest installation package (tar.gz) to the <INSTALL_DIR>/integration/docker directory.
  2. Open the Dockerfile in the <INSTALL_DIR>/integration/docker directory to review and modify its contents as needed.
  3. Open the jtestcli.properties file in the <INSTALL_DIR>/integration/docker directory to configure the license settings and other Jtest configuration settings (see Licensing and Configuring Jtest).
  4. Run the following command in the <INSTALL_DIR>/integration/docker directory to build the image:

    docker build -t jtestcli:latest

    The image will include runnable Jtest and other tools you specified in the Dockerfile.

Licensing and Configuring Jtest

You can license and configure Jtest before the container image is built. This allows you to provide a default Jtest configuration to all users of the image. 

To license and configure Jtest, add the license and configuration settings to the jtestcli.properties file in the <INSTALL_DIR>/integration/docker directory.

You must configure a network license to run Jtest in a Docker container. The local license is not supported. See Setting the License for details.

See Configuration for details about configuring Jtest and a complete list of available settings.

Running Jtest from the Container Image

Once you built the Docker container image that includes Jtest, you can utilize all of the Jtest's capabilities available from the command line interface. If Jtest was not licensed and configured when the image was built, you need to create a jtest.properties file in the current directory and configure the license and other options before you run (see Configuration).

You must accept the Parasoft End User License Agreement (EULA) to run Jtest by setting the ACCEPT_EULA variable to true. The Parasoft EULA is available in the Jtest installation directory and at https://www.parasoft.com/license.

Use the following command to run Jtest from the image:

docker run --rm -v $PWD:/home -w /home -e ACCEPT_EULA=false jtestcli [Jtest command line options]

Examples

The following examples show how to run Jtest from the Docker container image to perform analysis and testing of the Jtest example project shipped in <INSTALL_DIR>/examples/demo.

Example1

The following command collects coverage from unit tests for a Gradle build:

docker run --rm -v "$PWD/build":/opt/parasoft/jtest/examples/demo/build -e ACCEPT_EULA=false -e EXEC="./gradlew" jtestcli jtest-agent test jtest -Djtest.config="builtin://Unit Tests" -I /opt/parasoft/jtest/integration/gradle/init.gradle

The Jtest report will be created in the 'build/reports/jtest' directory.

Example 2

The following command executes static analysis and collects coverage from unit tests for a Maven build:

docker run --rm -v "$PWD/target":/opt/parasoft/jtest/examples/demo/target -e ACCEPT_EULA=false -e EXEC="./mvnw" jtestcli test-compile jtest:agent test jtest:jtest -Djtest.config="builtin://Demo Configuration"

The Jtest report will be created in the 'target' directory.

Example 3

The following command executes static analysis on a custom JSON file:

docker run --rm -v $PWD:/home -w /home -e ACCEPT_EULA=false jtestcli -data /opt/parasoft/jtest/examples/demo/demo.data.json



  • No labels