---
url: /reference/upload-formats-and-samples/testwise-coverage.md
---

# Testwise Coverage

\[\[toc]]

## Report Format

Testwise Coverage is a Teamscale-specific coverage format that allows to express coverage information on a per test level.

::: tip Versions
There are two versions of this report format.
Version 2 is supported in Teamscale 7.8 and later.
Version 1 is still supported for backwards compatibility.
This document describes the version 2 of the Testwise Coverage report format.
You can still find the [documentation of the version 1 format here](./version_1/).
:::

### Preliminaries

* Uniform path
  * File path like string that represents a hierarchy. Parts of the hierarchy are delimited by slashes.
* Line range string
  * String containing line ranges and individual lines separated by commas.
  * Compact representation of a set of lines of code.
  * Example: `"10-12,13,22-27,40"`

### TestwiseCoverageReport

The top level JSON object is the `TestwiseCoverageReport`. It contains the following attributes:

### FileInfo

Information about a covered file. It contains the following attributes.

### TestInfo

### ExecutionUnit

Represents a set of tests that is executed together.
An execution unit in the Testwise Coverage report can either contain a subset or all of the tests that are executed as one unit.
Examples include test binaries built for C/C++ code or test Jar files for Java code.
During the build process, all tests included in an execution unit will be executed at once to avoid overhead.
It contains the following attributes.

## Sample File

The following JSON sample file combines the necessary data described above.

```json
{
  "version": 2,
  "partial": true,
  "methodAccurate": false,
  "files": [
    {
      "path": "example_project/src/com/example/project/Calculator.java"
    },
    {
      "path": "example_project/test-src/com/example/project/CalculatorTest.java"
    }
  ],
  "tests": [
    {
      "uniformPath": "com/example/project/CalculatorTest/testAddition()",
      "duration": 1.5,
      "result": "PASSED",
      "coverage": {
        "0": "20-24,26,27,29",
        "1": "17-22"
      }
    },
    {
      "uniformPath": "com/example/project/CalculatorTest/testSubtraction()",
      "duration": 2.0,
      "result": "PASSED",
      "coverage": {
        "0": "20-24,26,27,29",
        "1": "17-22"
      }
    }
  ],
  "executionUnits": [
    {
      "uniformPath": "unit-tests/calculator-tests",
      "result": "PASSED",
      "hash": "74E9F552F9543754373D4F07EB9D190E746A574A",
      "coverage": {
        "0": "20-24,27,29",
        "1": "19-25"
      },
      "tests": [
        {
          "uniformPath": "com/example/project/CalculatorTest/testMultiplication()",
          "duration": 3.0,
          "result": "PASSED"
        },
        {
          "uniformPath": "com/example/project/CalculatorTest/testDivision()",
          "duration": 4.0,
          "result": "PASSED",
          "associatedSpecItems": [
            "requirements-connector1|DP-3",
            "requirements-connector1|DP-4"
          ]
        }
      ]
    }
  ]
}
```
