Cucumber and Code Coverage

Maybe a long shot question here, maybe a bit philosophical…

Is it possible to include Cucumber (aka BDD) in Code Coverage ?

For the Java world, I’m not even sure this is a sonar question or a Jacoco question (probably both…).

For legacy applications with very poor coverage and poor testability, the immediate benefit would be to increase code coverage when some classes might prove impossible to test unitarily. For a coach of such applications, that could mean: giving the dev teams something to start with, some encouragement…

For applications with an already good code coverage and high testability, I not sure. As a Tech Leader or a coach, I would sure be very interested in having the code covered by my Cucumbers, at least to see if the use cases I want to cover are actually covered by my Cukes.

I would love to have your opinion about this, maybe your feedback if you have any. Of course technical setup to do exactly THAT with Jacoco is most welcome!

Hey there.

One of the great things about SonarQube is that we use a unified coverage metric that accepts whatever reports you throw at it, so it’s ultimately a combo of unit tests + integration tests + whatever else you have.

So as long as you have a JaCoCo report with the results of your Cucumber tests – yes, they could be included in your code coverage.

We have no particular knowledge about Cucumber here, but a quick google search for JaCoCo + Cucumber showed some promising resources out there.

Yep, OK. I think I see where this goes.
Thx for the info!

Kind regards