You can easily discover the degree to which the code of your solution is covered with unit tests using
When you install dotCover, several new options appear in the ReSharper menu, such as Cover Unit Tests and Cover All Tests from Solution. Choosing Cover Unit Tests, runs code coverage on tests from currently selected scope. Cover All Tests from Solution runs code coverage on all tests in the solution. As a result you get information about which source code is covered by unit tests.
NotedotCover integrates with ReSharper 5.0 or higher.
- Choose a test class or a test method.
- Click the corresponding side bar mark in the left gutter.
- In the context menu, choose Cover with dotCover:
- The Unit Test Sessions window opens and unit tests are running. After this process is completed, coverage analysis will run and coverage snapshot will be displayed in the new Coverage tab.
- Open the Unit Test Sessions window by choosing ReSharper | Windows | Unit Test Sessions or pressing Ctrl+Alt+R. If you haven't yet arranged a test session, see
Running and Debugging Unit Testsfor guidelines.
- Select a node in the tree view of the Unit Test Sessions window, and click Cover Selected Tests in the toolbar.
- You can get coverage reports for entire solution or for tests from a certain scope. Depending
on your goals do one of the
- On the main menu, choose ReSharper | Unit Tests| Cover All Tests from Solution. All tests will be covered.
- Select a node in the Solution Explorer window. On the main menu, choose ReSharper | Unit Tests | Cover Unit Tests. The tests from chosen scope will be covered.
- One way or another, the Unit Test Sessions window opens and unit
tests are running. After this process is completed, coverage analysis will run and coverage
will be displayed in the new Coverage tab.
dotCover provides two measurements: percentage of code covered and number of code statements. For instance, if there are 15 statements out of which 10 are covered with tests, that should indicate 66% coverage. You can choose a node and click Highlight Code icon to indicate which statements are covered by tests that have been run. Lines that are highlighted green were exercised in the test run, and lines that are highlighted red were not.