Is it possible to embed code coverage results (stored in SonarQube) into Github projects as one of those embeddable icon gadgets (not sure what their name is; it would be great if somebody to tell me that as well)...? I'm referring to the ones that show the build status, for example.
Code coverage, also called test coverage, is a measure of how much of the application's code has been run in testing. Essentially, it's a metric that many teams use to check the quality of their tests because it represents the percentage of the production code that has been tested and run.
Using a plugin in no longer needed, as some new APIs are now added that will do what you want. You can use this snippet in your .md
files:
[![SonarCloud Coverage](https://{domain}/api/project_badges/measure?project={projectName}&metric=coverage)](https://{domain}/component_measures/metric/coverage/list?id={projectName})
Note that you have to replace parameters inside {}
s with your own values. If you are using on-premise version, the domain
will be your own domain and if you are using cloud version, it will be sonarcloud.io
.
Also note that this will work only for public projects. For private ones, I could not find any solution.
And finally as a side note, the metric
parameter takes some values other than coverage
and gives other fantastic badges that you may find helpful:
bugs, code_smells, coverage, duplicated_lines_density, ncloc, sqale_rating, alert_status, reliability_rating, security_rating, sqale_index, vulnerabilities
The only thing currently available is this under-development plugin, which was first discussed in this Google Group thread. Note that this project appears to be in its infancy.
EDIT
This plugin has since been released, and can be installed directly from the Update Center
EDIT 2
With SonarQube 7.1, badges become a native feature.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With