Build/Test Issues

No coverage for [SetUpFixture] class (NUnit)?

Started by GreenMoose on 6,756 views

[NUnit 2.5.7]
I have some test-assembly specific setups via [SetUpFixture], but the [SetUp] method in this class is never marked as covered.

Is this expected behavior or is it a bug?

In my case I have the class in the assembly's root namespace so it should be 1-time setup for all tests in that assembly.

p.s. When altering the setup in this class tests are not re-run with setting "run impacted tests automatically", but explicitly running test which is dependent on that setup code causes it to fail, so the setup method is indeed run d.s.

Thanks.
NCrunch relies on normal NUnit logic to always call the code in SetUpFixtures, so the code will be run. However, as NCrunch doesn't have a test to actually represent the SetUpFixture itself, it won't record any code coverage for this path of execution.

So in short, this is a known issue. Most likely it will need to be resolved as part of a longer term plan - perhaps by introducing the concept of a SetUpFixture 'test' to hold the coverage.

Thanks for taking the time to report this!


Cheers,

Remco
Just for follow up since this issue is still biting me. Another coverage tool I am using does indeed cover these classes (due to other coverage "calculation logic"?) so it's a bit pity I can't use NCrunch for these scenarios to ensure 100% coverage (except for excluding those classes from metrics that is).
Thanks for your feedback. It's quite a significant adjustment to change the way that this works, so I'm afraid that no changes in this area will be released as part of a minor revision. If this feature is changed, it will likely be in V2 or beyond.


Cheers,

Remco

Post a reply

Log in to reply.