Reputation: 20022
b.s Specflow, Unit Test
I am implementing Statement Coverage in Unit Tests, i have identified the if conditions, try catch blocks e.t.c and i will be writing scenarios which will cover all the code giving 100% statement coverage to my unit test..
The problem is I know that these scenarios are doing 100% code coverage, anybody else who will run these tests have no clue how much statement coverage it is providing. There is no output of tests or any thing else which can tell other about the statement coverage percentage.
How to do it || How it is done
Upvotes: 2
Views: 6711
Reputation: 6961
The best practice (which your comment indicates you should be following) would then be to set up a build server. Any old box will do, even your own, but in a reasonable sized enterprise make sure you transition to a proper box once you've demonstrated the proof of concept.
I'll assume you've already got version control in your organisation, which will mean that the build server can work on a copy of your code.
I would install TeamCity (its free for 20 build configurations) and use its web based interface to set up a build. You simply add a step for Visual Studio and point it at your solution. Add another step for NUnit, and tick the box to get coverage results.
Most importantly you also get a trend of what's going on, for example
This project is UI hence the low coverage and I also rolled back a redesign that didn't work out, leading to the drop in tests.
There are plenty of details on the TeamCity website
However the best way to see what code is covered has to be NCrunch as @Steve commented. I use this all the time too, and not only do you get to run your tests as quickly as possible, and you get to see which lines are affected, but you also get really good test debugging support.
Upvotes: 3