Code Coverage - Get Test Run Code Coverage
Get code coverage data for a test run
GET https://dev.azure.com/{organization}/{project}/_apis/test/Runs/{runId}/codecoverage?flags={flags}&api-version=7.1
URI Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
|
organization
|
path | True |
string |
The name of the Azure DevOps organization. |
|
project
|
path | True |
string |
Project ID or project name |
|
run
|
path | True |
integer (int32) |
ID of the test run for which code coverage data needs to be fetched. |
|
api-version
|
query | True |
string |
Version of the API to use. This should be set to '7.1' to use this version of the api. |
|
flags
|
query | True |
integer (int32) |
Value of flags determine the level of code coverage details to be fetched. Flags are additive. Expected Values are 1 for Modules, 2 for Functions, 4 for BlockData. |
Responses
| Name | Type | Description |
|---|---|---|
| 200 OK |
successful operation |
Security
oauth2
Type:
oauth2
Flow:
accessCode
Authorization URL:
https://app.vssps.visualstudio.com/oauth2/authorize&response_type=Assertion
Token URL:
https://app.vssps.visualstudio.com/oauth2/token?client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer
Scopes
| Name | Description |
|---|---|
| vso.test | Grants the ability to read test plans, cases, results and other test management related artifacts. |
Examples
Sample request
GET https://dev.azure.com/fabrikam/Fabrikam-Fiber-TFVC/_apis/test/Runs/51/codecoverage?flags=7&api-version=7.1
Sample response
{
"value": [
{
"testRun": {
"id": "51",
"name": "buildguest@BUILD-0002 2015-06-09 10:32:28_Any CPU_Debug",
"url": "https://dev.azure.com/fabrikam/Fabrikam-Fiber-TFVC/_apis/test/Runs/51"
},
"state": "0",
"lastError": "",
"modules": [
{
"blockCount": 2,
"blockData": "Aw==",
"name": "fabrikamunittests.dll",
"signature": "c27c5315-b4ec-3748-9751-2a20280c37d5",
"signatureAge": 1,
"statistics": {
"blocksCovered": 2,
"linesCovered": 4
},
"functions": []
}
]
}
],
"count": 1
}
Definitions
| Name | Description |
|---|---|
|
Coverage |
|
|
Function |
|
|
Module |
|
|
Shallow |
An abstracted reference to some other resource. This class is used to provide the build data contracts with a uniform way to reference other resources in a way that provides easy traversal through links. |
|
Test |
Test Run Code Coverage Details |
CoverageStatistics
| Name | Type | Description |
|---|---|---|
| blocksCovered |
integer (int32) |
|
| blocksNotCovered |
integer (int32) |
|
| linesCovered |
integer (int32) |
|
| linesNotCovered |
integer (int32) |
|
| linesPartiallyCovered |
integer (int32) |
FunctionCoverage
| Name | Type | Description |
|---|---|---|
| class |
string |
|
| name |
string |
|
| namespace |
string |
|
| sourceFile |
string |
|
| statistics |
ModuleCoverage
| Name | Type | Description |
|---|---|---|
| blockCount |
integer (int32) |
|
| blockData |
string[] (byte) |
|
| fileUrl |
string |
Code Coverage File Url |
| functions | ||
| name |
string |
|
| signature |
string (uuid) |
|
| signatureAge |
integer (int32) |
|
| statistics |
ShallowReference
An abstracted reference to some other resource. This class is used to provide the build data contracts with a uniform way to reference other resources in a way that provides easy traversal through links.
| Name | Type | Description |
|---|---|---|
| id |
string |
ID of the resource |
| name |
string |
Name of the linked resource (definition name, controller name, etc.) |
| url |
string |
Full http link to the resource |
TestRunCoverage
Test Run Code Coverage Details
| Name | Type | Description |
|---|---|---|
| lastError |
string |
Last Error |
| modules |
List of Modules Coverage |
|
| state |
string |
State |
| testRun |
Reference of test Run. |