covered icon indicating copy to clipboard operation
covered copied to clipboard

"require" is considered uncovered

Open swrobel opened this issue 4 years ago • 2 comments

Is this by design, or an oversight? this leads to drastically different results than simplecov when files have a lot of requires

swrobel avatar Apr 21 '20 17:04 swrobel

You need to ensure your code is not loaded before starting coverage. Otherwise, all the global behaviour is already executed.

e.g. https://github.com/socketry/async/blob/master/spec/spec_helper.rb#L3

I do not load library code here. It gets loaded by the specific rspec tests. This actually makes rspec a bit faster and more predictable when running individual tests.

ioquatix avatar Apr 21 '20 23:04 ioquatix

I believe everything is setup properly, but you can check here: https://github.com/swrobel/invoker/commit/e744da293aaf5140959e75262b86d29fceca3092

Example well-covered file that doesn't count require Screen Shot 2020-04-22 at 2 21 50 PM

swrobel avatar Apr 22 '20 21:04 swrobel

The latest version should be significantly improved in this regard, can you please try again and let me know if it's still an issue?

ioquatix avatar Jun 30 '23 14:06 ioquatix

I'm not sure what to make of this, but this is what 0.21.0 reports, which is also incorrect:

* 54 files checked; 0/0 lines executed; 100.0% covered.

swrobel avatar Jun 30 '23 14:06 swrobel

You still need to do this: https://github.com/swrobel/invoker/commit/e744da293aaf5140959e75262b86d29fceca3092#r38690565

ioquatix avatar Jun 30 '23 21:06 ioquatix