---
url: /reference/ui/metrics/tests.md
---
# Tests View

The *Tests* view displays all tests that are known to Teamscale.
Tests can be added to Teamscale by [Uploading Test Execution reports](../../../upload-formats-and-samples/#supported-formats-for-upload) in one of the [supported formats](../../../supported-technologies/test-frameworks/#test-execution-formats) and by [extracting tests](../../../supported-technologies/test-frameworks/#test-implementations) directly from the actual source code.

## Hierarchical view

The tests are displayed in a hierarchical structure based on the path of the test.

![Test Metrics View](./test-metrics.png)

### Actions

This view contains two actions:

* **Link** The  button adds a link to this view to the clipboard.
* **Filter** The  button switches to the test filter view.

### Metrics

The available metrics are:

* *Count*: The count of tests in the container
* *Failed*: The count of tests that have failed in the latest test run
* *Skipped/Ignored*: The count of tests that have been skipped (i.e. because they are not compatible with the execution platform) or ignored (i.e. the test is disabled in the code or test configuration)
* *Successful*: The count of tests that have passed in the latest test run
* *Result*: The aggregated assessment of the previously listed test execution results
* *Duration*: The aggregated test execution duration

You can click on any of the metrics to see a trend of the metric over time and a treemap of the included elements that shows which of the elements is affected by the metric.

![Test Metrics Dialog](./test-metrics-dialog.png)

## Test Filter View

The filter view allows to filter tests based on certain criteria.

### Actions

This view contains two actions:

* **Hierarchy** The  button brings you back to the hierarchical view on the tests
* **Switch to query language** The  button switches the view from the basic mode to the query language mode.
  The query language gives you much more power over which tests should be selected.

### Basic Mode

![Test Filter View - Basic Mode](./test-filter-basic.png)

* *Name*: Allows to specify a regular expression that is matched against the test names
* *Duration*: Allows to specify a threshold for the upper or lower bound of test executions
  Note that this always takes the maximum duration of all partitions.
  If you need more fine grained control over how partitions are treated, switch to the query language mode.
* *Result*: Allows to specify which results should be included in the results

### Query Language Mode

For example, to display all tests that fail on one platform, but pass on another one, enter `result() in [failed, error] && result() in [passed]` into the query box.
After pressing *Enter*, the list of matching tests is displayed below the box.
The input box also provides autocompletion to simplify writing queries.

![Test Filter View - Query Language Mode](./test-filter-query.png)

Each test in the returned list provides a link to additional details, the partition, duration and result of their execution.
The partition selector in the top right can be used to hide the durations and results of partitions you are currently not interested in.
If you want to remove tests from certain partitions from the results entirely, you need to filter them out via the query.
For example `partitions !in [Windows]` shows only the tests that have no execution information for the Windows partition.

#### Test Query Language

Some interesting use cases could be:

* Tests that fail in at least one partition (track failing tests)

```
result() in [failed, error]
```

* Tests that fail in one partition and pass in another (track inconsistent test results)

```
result() in [failed, error] && result() in [passed]
```

* Test that have been failing for longer than 14 days
  Failing tests are fine, actually that’s what they are made for, however, they should be fixed soon

```
inState(result() in [failed, error]) > 14d
```

* Tests that have a duration > X sec. (track long running tests)

```
max(duration()) > 30s
```

or for a specific partition

```
max(duration('Unit Tests')) > 10s
```

* Tests that have never failed (track candidates of “useless” tests)

```
inState(result() !in [failed, error]) > 1970-01-01
```

### Test Query Metrics

You can store a query as a metric with the  *Add as metric* button.
It will then show up in the right sidebar.
Stored test query metrics can then be referenced from other places like the metric-related dashboard widgets.

![Numeric Metric Value widget with test query](./test-query-dashboard.png)
