Testwise Coverage
Report Format
Testwise Coverage is a Teamscale-specific coverage format that allows to express coverage information on a per test level.
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.
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:
version | int | required |
|
partial | bool | optional |
|
files | Array<FileInfo> | required |
|
executionUnits | Array<ExecutionUnit> | optional |
|
tests | Array<TestInfo> | optional |
|
FileInfo
Information about a covered file. It contains the following attributes.
path | string | required |
|
coverableLines | string | optional |
|
TestInfo
uniformPath | string | required |
|
parameters | Array<{value:string, name?:string}> | optional |
|
hash | string | optional |
|
duration | float | required | The duration in seconds it took to execute the test. |
result | string | required | Describes the result of the test execution. Can be one of:
|
message | string | optional | Error message and stacktrace or skip reason. |
coverage | Map<string,string> | optional | A map of strings to line range strings. The keys are the integer indexes in string form of the FileInfo objects in the top-level files array. The values are the line range strings representing the covered lines. |
associatedSpecItems | List<string> | optional | A list of specification items that this test verifies. An ID can be specified using a combination of requirements tracing connector name and specification item ID (e.g. req-connector|spec-item-id ) or using a format matching the Specification item ID pattern option if this option has been set in the respective connector. |
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.
uniformPath | string | required |
|
hash | string | optional |
|
duration | float | required | The duration in seconds it took to execute the execution unit. |
result | string | required |
|
coverage | Map<string,string> | required |
|
tests | Array<TestInfo> | optional |
|
Sample File
The following JSON sample file combines the necessary data described above.
{
"version": 2,
"partial": true,
"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",
"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"
]
}
]
}
]
}