Skip to content

How to Set up Similarity Scoring ​

Similarity Scoring suggests the tests to run for a set of code changes, for example, a pull request, an issue or a release. It ranks your tests by how similar the text of their implementation is to the changed code. It needs no testwise coverage, so it is the easiest change-based test selection technique to set up.

Prerequisites ​

Selecting Tests in the Teamscale UI ​

  1. Open the Test Suggestions perspective and select the Change-Based view.
  2. Define the risky code in the left panel. For example, select all changes since a baseline or the changes of an issue query.
  3. Optionally, restrict the test candidates in the Test Candidates section.
  4. Click Select Tests From Candidates.
  5. Open the Related Test Implementations tab. It lists your tests by Content Relevance, the most relevant first.
  6. Select a subset of the list with the Number of tests (budget) selector.

The Test Suggestions perspective reference describes all options of this view.

Selecting Tests from the Command Line ​

The teamscale-dev command line client fetches the tests for the last commit on your current branch:

shell
teamscale-dev fetch-impacted-tests --strategy SIMILARITY src/

Without --strategy, the client uses testwise coverage if your project has any and Similarity Scoring otherwise. The fetch-impacted-tests reference describes all options.

AI coding agents can use the same selection through the Claude Code plugin.

Improving the Results ​

Teamscale removes stop words such as public or void before it compares tests and changes. You can adjust these stop words for each programming language, as described in the stop words reference.

Once you record testwise coverage, you can add Test Impact Analysis. It selects the tests that actually execute the changed code.