1

I'm running nose2 tests with the coverage plugin. I noticed that decorators, class declarations, and function definitions aren't being marked as covered, even though the "actual code" underneath them is. I found this answer, which suggests starting coverage "earlier."

How would I do this via nose2? I tried exporting NOSE_WITH_COVERAGE=True, but that didn't seem to do anything.

Additional context: eventually we're hoping to plug these tests into Jenkins, if that matters.

ETA: adding a [coverage] section with always-on = True to my nose2.cfg didn't work.

Community
  • 1
  • 1
swizzard
  • 1,037
  • 1
  • 12
  • 28

1 Answers1

0

The fool-proof way to get coverage started earlier is to use coverage to run nose, instead of using nose to run coverage. For example, instead of:

$ nose2 blah blah blah

you can use:

$ coverage run -m nose2 blah blah blah

and then just leave out the nose coverage options from blah blah blah.

Ned Batchelder
  • 364,293
  • 75
  • 561
  • 662
  • @swizzard: You'll have to show exactly the command line you used. Your problem is a common one, and running nose inside coverage is the best solution. It will work for you. – Ned Batchelder Nov 04 '14 at 22:46
  • `coverage run -m nose2 --plugin nose2.plugins.junitxml --junit-xml` results in the non-test code being under-counted, essentially reversing what's counted as "covered". – swizzard Nov 06 '14 at 18:42
  • @swizzard: I don't know why that would be. If you could send more details (including steps to reproduce) in an email, we can get to the bottom of it. – Ned Batchelder Nov 06 '14 at 22:06