Search code examples
c#testingnunitcode-coveragencover

How to discover which test unit checks which lines of code?


I was fooling around the NUint, hoping to discover a way to realize which line of code passes in which test.

Imagine I have a method for which I have 3 tests. Is there any way to find out which test checks which line of code?

Having used NCover, I know you can find out which lines have been tested and which have not. However, you really can't see which unit checked that code.

It can be really useful when dealing with tons of tests...


Solution

  • JetBrains dotCover can help you to get the info you are looking for. It integrates with the ReSharper unit test runner and collects per-test data. You can see which code is covered by the each particular test (with corresponding highlighting in VS). And what is more interesting, for every piece of code you can get list of tests which cover it and easily rerun them.

    Additional info is available here: http://blogs.jetbrains.com/dotnet/2010/07/show-covering-test-with-dotcover/