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.
Provided you’re testing a Ruby application, recording your code coverage from Cucumber tests is pretty easy. For Ruby 1.8 applications, you can use Cucumber’s built-in Rake task:
legacy_applications/Rakefile | |
| require 'cucumber/rake/task' |
| |
| Cucumber::Rake::Task.new ... |
Get The Cucumber Book now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.