In Visual Studio, I just created a simple Unit Test to test a method I wrote. I wanted to check the code coverage, but the Code Coverage window only ever states that "Code Coverage is not enabled for this test run". Why? Note:
Yet I still get the message "Code Coverage is not enabled for this test run" every time I run the relevant test. How do I enable Code Coverage once and for all?
I used to struggle with MSTest, in a lot of areas (including code-coverage) - frankly, it* doesn't exactly go out of its way to make life easy - especially with the extra testrunconfig etc duplicating a lot of things already in the csproj.
Anyway; than I found that TestDriven.NET has this built in (as long as you have the right edition of Visual Studio to include MSTest and coverage):
(source: mutantdesign.co.uk)
This will use your existing test framework (including MSTest), but it will jump through all the usual hoops to get test coverage enabled, without you needing to mess with the configuration. It even works with the source-code colorization (red/blue untested/tested etc). Handy.
*=the tool itself, and the GUI integration
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With