Set up Test Intelligence

Updated 2 weeks ago by Manish Jaiswal

Test Intelligence (TI) dramatically improves test time by running only those tests required to confirm the quality of the code changes which triggered the build. You can enable Test Intelligence for your build in your CI stages using the Run Tests steps.

In this topic, we'll cover how to set up Test Intelligence in Harness CI Stage.

Before You Begin


Test Intelligence is supported for Java-language codebases only at this time.

Step 1: Create the CI Stage

In your Harness Pipeline, click Add Stage, and then click Build.

Step 2: Add the Codebase

Do one of the following:

  • If this is the first CI stage in the Pipeline, in the Build stage settings, enable Clone Codebase.
  • If you have an existing Pipeline with a Build stage, click Codebase to configure your codebase settings.

See Edit Codebase Configuration.

Step 3: Define the Build Farm Infrastructure

In the Build stage Infrastructure, define the build farm for the codebase. See Kubernetes Cluster Build Infrastructure Setup.

Step 4: Configure a Run Tests Stage

In the Build stage Execution, click Add step and then click Run Tests.

The Run Tests step executes one or more commands on a container image.

The following screenshot explains the various parameters of Configure Run Tests Step. See also Run Test Step Settings.


Enter a unique name for the step.


Enter a description for the step.

Container Registry

The Harness connector for a container registry. This is the container registry for the image Harness will use run build command on, such as Docker Hub.


The name of the Docker image to use for running the build commands. Enter a Fully Qualified Image Name(FQIN) when using a private container registry.


Enter the arguments for the build tool. These are used as input for the build tool choice.

Build Tool

Enter the build automation tool. Currently, Harness supports Bazel, Maven, and Gradle.


Enter the programming language of the source code to build. For example Java.


List of source code package prefixes supported by a comma. For example,, migrations.

Step 5: Perform the Bootstrap

Bootstrapping helps generate the initial call graph for Test Intelligence. Once the call graph is generated, TI can perform Test Selection. Perform the bootstrap in the following steps:

Configure the Webhook.

You can trigger Pipelines in response to Git events automatically. For configuring the webhook for the Trigger, see Add a Trigger

Open the PR.

Note: This PR should trigger all the tests (pom.xml, non-Java, etc.)

Merge the PR.

Step 6: View the Test Report

Once the Pipeline is executed, click Tests. Tests shows the test report of the test you configured and ran. 

Test Execution Overview

Displays the overview of Total Test, Tests Selected, Duration of the Selected Tests, and Time Saved.

Test Execution Result

Displays the graphical representation of the successful and failed tests.

Test Selection Breakdown

Displays the selection of Tests on the following metrics: changed code, changed tests, and new tests.

Test Execution

Displays the detailed list of all tests: class methods and test methods.

Call Graph

A call graph is generated once the bootstrap is completed. In each later run, the test tab will display stats corresponding to the selection. 


Visualization shows why a specific test was selected and the reason behind every test selection. Click on any test (the purple node), and you can see all the classes and methods covered by this test. These are the changed classes and methods (denoted by the blue nodes), which led to the selection of that test.

Optional: YAML Configure As Code

Here's a working example of Test Intelligence on the open-source project Dubbo. Use this YAML template to create and configure the TI pipeline on the go.

name: ti-dubbo
identifier: tidubbo
connectorRef: account.howdi
repoName: dubbo
build: <+input>
- stage:
name: unit-test
identifier: unitteststi
type: CI
cloneCodebase: true
- step:
type: RunTests
name: runTestsWithIntelligence
identifier: runTestsWithIntelligence
connectorRef: account.GCR
image: maven:3-openjdk-8
args: test -Dmaven.test.failure.ignore=true -DfailIfNoTests=false
buildTool: Maven
language: Java
packages: org.apache.dubbo,
runOnlySelectedTests: true
type: JUnit
- "**/*.xml"
memory: 2Gi
cpu: 2000m
timeout: 60m
serviceDependencies: []
type: KubernetesDirect
connectorRef: Kubernetes_Quickstart
namespace: harness-delegate
variables: []
projectIdentifier: CD_Examples
orgIdentifier: default
description: TI for open source project dubbo
tags: {}

See Also

Please Provide Feedback