I came across some strange results when using Code Coverage for our unit tests.
In the AssemblyInitialize function we do some initialization work (like AutoMapper, AbstractFactories) and this function is correctly executed.
The strange thing is that Code Coverage shows that there is no coverage for the functions that are called from AssemblyInitialize. Is this by design or am I doing something wrong here?
I would go with as by-design it seems too specific to be anything other. As someone who is looking into doing similar for an open source coverage tool it seems odd for this to be an accident and would be a very unusual bug.
The TDD purist in me would say this is because the setup/teardown of any type (assembly/class) is not actually part of the test itself and so should not be included in coverage. You should instead have separate, specific tests for that code rather than rely on the test setup/initialization failing.
Other .NET tools (dotCover for one) does coverage by test and ‘may’ also exclude results gained whilst running such setups; this is conjecture rather than known fact though.