---
url: /howto/setting-up-similarity-scoring.md
---

# How to Set up Similarity Scoring

[Similarity Scoring](../../introduction/test-selection/#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.

\[\[toc]]

## Prerequisites

* Your Teamscale project contains your test code, and Teamscale recognizes the [implementations of your tests](../../reference/supported-technologies/test-frameworks/#test-implementations).
  If your test framework is not supported out of the box, you can declare your tests as [generic file-based test implementations](../../reference/supported-technologies/test-frameworks/#generic-file-based-test-implementations).
* You have the *Retrieve Test Suggestions* permission in the project, see [Project Permissions](../../reference/permission-management/#project-permissions).

## 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](../../reference/ui/test-suggestions/#results-related-test-implementations-similarity-scoring) 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](../../reference/cli/teamscale-dev/#the-fetch-impacted-tests-command) describes all options.

AI coding agents can use the same selection through the [Claude Code plugin](../integrating-with-claude-code/).

## 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](../../reference/ui/test-suggestions/#stop-words).

Once you record [testwise coverage](../../glossary/#testwise-coverage), you can add [Test Impact Analysis](../../introduction/test-selection/#test-impact-analysis).
It selects the tests that actually execute the changed code.
