O'Reilly logo

The Cucumber Book, 2nd Edition by Steve Tooke, Aslak Hellesoy, Matt Wynne

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

Code Coverage

Code coverage tools allow us to discover which specific lines of code in the system were executed during a test. When you are starting to add tests to a legacy application, it can be really useful to know your code coverage:

  • If you know that a line of code isn’t covered by your tests yet, you can see more clearly what kind of a characterization test you need to write.

  • If you know that a line of code is covered by your tests, you can be more confident in refactoring or changing it.

There is no built-in support in Cucumber for collecting code coverage statistics. Instead, you need to install the SimpleCov[56] gem and add a couple of lines to your env.rb:

 require ​'simplecov'
 SimpleCov.start

When your features finish running, ...

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