O'Reilly logo

Continuous Integration, Delivery, and Deployment by Sander Rossel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Including code coverage

We can also include our code coverage results in SonarQube and set rules in our quality gates. For example, we can set the minimum amount of coverage or the minimum amount of coverage for new code.

According to the documentation, SonarQube supports the Cobertura format for code coverage out of the box. Unfortunately, I was never able to get that to work. Luckily, we can get it to work with the LCOV format. Getting an LCOV report is as easy as adding it to the coverage reporters in your Karma configuration:

[...]   coverageReporter: {      reporters: [         { type : 'html', subdir: 'html' },         { type : 'cobertura', subdir: 'cobertura' },         { type : 'lcov', subdir: 'lcov' }      ],[...]

Now, adding code coverage to SonarQube is as easy as ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required