views:

53

answers:

2

I have a bunch of unit tests in my visual studio project and code coverage coloring shows the covered lines of code in blue. Is it possible to jump to the unit test(s) that covers that line of code?

+3  A: 

No. Several unit tests may cover the same line, so it's not a 1-1 relationship.

Your best bet is to stick a breakpoint on the line and run the tests and look at the call stack when the break point is hit.

Simon P Stevens
+1  A: 

An alternative method is to change that line of code, maybe comment it out, and see which tests fail as a result. May well be quicker than having to manually check each time the breakpoint is hit.

Garry Shutler
Yeah, nice idea. Perhaps put an Assert.Fail on the line before, with a specific message and see which tests fail with that message.
Simon P Stevens
Yeah, that would work for tests that test the method. My way would try to find those that rely on the line of the method. Nice idea though.
Garry Shutler