Since a couple of weeks (at least) it appears that the SonarCloud “GET measures” API no longer returns several test-related measures, even though the metrics are still supported according to the “GET metrics” API.
Steps to reproduce:
- Call the GET api/metrics/search API with
ps=500to get all of them in one go: https://sonarcloud.io/api/metrics/search?ps=500 - Search for keys that start with “test” – e.g. by searching for
"key": "test; note these down. - Pick a SonarCloud project that has been scanned, and where you have passed test (coverage) information (e.g. using a JaCoCo data file); note down the project key.
- Call the GET api/measures/component API and pass the
component=KEY(replaceKEYwith your actual project key) andmetricKeys=XXX(replaceXXXwith the keys you noted down in step 1 plusncloc, comma-separated) – e.g. in the case of project keyacme-utils: https://sonarcloud.io/api/measures/component?component=acme-utils&metricKeys=test_execution_time,test_errors,test_failures,test_success_density,tests,ncloc
Expected Results:
Call in step 1 succeeds with a 200 OKand valid JSON.
The JSON from step 1 contains at least dozens of metrics.
Step 2 returns with a 200 OK, and valid JSON.
In step 2, in the JSON, you find these metric keys: test_execution_time,test_errors,test_failures,test_success_density,testsandncloc(order is irrelevant).
Actual results:
Call in step 1 succeeds with a 200 OKand valid JSON.
The JSON from step 1 contains 112 metrics.
In step 2, we indeed get these metric keys: test_execution_time,test_errors,test_failures,test_success_density,tests(order is irrelevant).
In the JSON, we only get ncloc, the other metrics are not returned.
Actual JSON returned in step 2 (only replaced both the project key and name by acme-utils):
{
"component": {
"id": "AYvTOZjQfHtM5VPZMJY4",
"key": "acme-utils",
"name": "acme-utils",
"qualifier": "TRK",
"measures": [ {
"metric": "ncloc",
"value": "31701"
} ]
}
}