dotCover | Show Covering Tests
dotCover provides a shortcut to detect which unit tests cover a particular statement in your code. In the Visual Studio editor, you can invoke a pop-up that lists covering tests and navigate directly to any of these tests. Additionally, from this pop-up you can instantly run them or add to an existing unit test session.
dotCover takes the information on the covering unit tests from the current coverage snapshot. Therefore, in some cases this information may be unavailable, and dotCover cannot perform this navigation:
- No coverage snapshot is open. In this case, the corresponding commands in the main and context menus are grayed out.
- No unit tests cover the current statement. In this case, the commands are active but the pop-up will show the following message: No tests cover this statement.
- The current snapshot was recorded during a manual test session or with the console runner . In this case, the coverage snapshot does not contain per-test information; the commands are active but the pop-up will show the following message: Current snapshot does not contain per-test info.
It is obvious that for the code not covered with unit tests, this navigation is impossible. Therefore, you can first highlight covered and uncovered code and then navigate from the code highlighted as covered.
- In the editor, place the caret at a code statement.
- Choose dotCover | Show Covering Tests in the menu or press Ctrl+Alt+K,T.
In the pop-up that appears, you will see the list of unit tests that cover the statement.
By default, the pop-up disappears as soon as you click anywhere outside it. If you want to leave the pop-up while you continue to work in the editor, click Pin Window and/or drag-and-drop it to the desired position.
- Double-click on the desired unit test to open it in the editor.
Another navigation destination that you can use to explore code coverage is Locating Code Items in Coverage Tree.