Project

General

Profile

Actions

Bug #5333

closed

Coverage library giving wrong results

Added by colszowka (Christoph Olszowka) over 13 years ago. Updated about 13 years ago.

Status:
Third Party's Issue
Target version:
ruby -v:
-
Backport:
[ruby-core:39611]

Description

I'm the author of the simplecov gem, a wrapper on top of the Coverage library. You can find it on Github at https://github.com/colszowka/simplecov

I keep getting reports from users that code they have cleary tested is not reported as covered (you can find it a discussion at https://github.com/colszowka/simplecov/issues/60). This was very hard to trace back since no one was able to give me code samples so far. A couple of days ago, a user finally came up with a sample rails application where this problem was visible in conjunction with FactoryGirl.

I tried this out using the Coverage library directly, and the result was the same: Creating the record directly reported the file as covered, doing the same with FactoryGirl reported a coverage of 0 for certain lines - even though they were executed.

I forked the application and added some instructions to the readme. You can find it at https://github.com/colszowka/coverage-bug

I verified this on the latest 1.9.2 release as well as 1.9.3-preview1:

ruby 1.9.3dev (2011-07-31 revision 32789) [x86_64-darwin11.0.0]
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.0.0]

I'm not sure why this happens in conjunction with FactoryGirl, but the code inside the if-statement is being executed in that case as well as I verified by adding a raise inside there and getting a correctly failing rspec suite.

Please let me know if you need any further information on this

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0