dotCover Help

Executing Tests and Analyzing Results

dotCover provides several ways to execute unit tests. Whichever way you choose, execution progress, results, and output are displayed in the Unit Test Sessions window.

Before running coverage analysis, make sure that the PDB information exists for all target assemblies. The safest choice would be to set the Debug as the build configuration.

In this topic:

Different ways of executing and covering unit tests

There are following ways to run, debug or cover unit tests:

  • Use one of the ways to execute tests in the current document.
  • Use one of the ways to execute tests in the project/solution,
  • If there is an existing unit test session, you can run, debug or cover some or all tests in the session:
    • Select tests that you want to execute in the Unit Test Sessions window and click Run Unit Tests toolbar__run_selected_tests / Debug Unit Tests uts_toolbar_debug_selected_tests / Cover Unit Tests uts_toolbar_cover on the toolbar or press Ctrl+T,R / Ctrl+T,D / Ctrl+T,H .
    • To run or cover all tests in the session, click Run All Tests uts_toolbar_run_all_tests or Cover All Tests icon_cover_all on the toolbar or alternatively, choose ReSharper | Unit Tests | Run Current Session or ReSharper | Unit Tests | Cover All Tests from Solution in the main menu or press Ctrl+T,Y / Ctrl+T,K .
  • You can run coverage on a remote machine.

As the tests are running, the execution progress is shown in the status bar under the toolbar or the Unit Test Sessions window and the Stop Execution uts_toolbar_stop_execution button becomes active. You can click this button to abort execution or coverage analysis of the tests.

If necessary, you can enable the Track Running Test uts_toolbar_track_running_test option on the toolbar. If it is on, the selection in the test tree switches automatically to the test that is currently running and the output panel always shows output of the current test during the execution.

You can also enable the Auto Scroll Output When Running Test icon_auto_scroll_output option to follow output of tests as they are running.

If necessary, you can always repeat execution or coverage analysis of the tests that you executed last by clicking Repeat Previous Run uts_toolbar_rerun on the toolbar, choosing ReSharper | Unit Tests | Repeat Previous Run in the menu or pressing Ctrl+T,T.

Analysing execution results and output

When the execution is over, the results are visualized in the Unit Test Sessions window.

dotCover_unit_tests_sessions_status

The output pane (which you can place on the right or on the bottom using the Show Output toolbar_show_preview button on the toolbar) displays output of the selected test. If the test is failed, dotCover also adds short information on the failure. You can use clickable links in the failure information to navigate directly to types and methods involved with the failure.

By default, dotCover wraps long lines in the output according to the current width of the output area. If necessary, you choose not to wrap long lines by clearing the Wrap long lines in Unit Test Session output check-box on the Tools | Unit Testing options page.

Status of each test in the Unit Test Sessions window is displayed with one of the following icons:

  • unit_test_status_progress - the unit test is currently executing.
  • unit_test_status_scheduled - the unit test is scheduled for execution in the current run.
  • unit_test_status_unknown - the unit test was not executed.
  • unit_test_status_passed - the unit test passed in the lats test run.
  • unit_test_status_failed - the unit test failed in the lats test run.
  • unit_test_status_ignored - the unit test was ignored in the last test run. Either it has the corresponding attribute (e.g. for NUnit tests) or it is included in a category that is .
  • unit_test_status_aborted - the unit test was aborted in the last test run.

The same icons are used to display status of grouping items (classs, projects, etc.)

The icons are also used on each session's tab to display the overall execution result of the sessions.

The corresponding icons on the status bar show how many tests are in each of the status. The ThemedIcon.UnitSession.Screen.[Gray] icon shows the total number of tests in the session.

Analysing coverage results

After running coverage analysis of unit tests, you can study coverage results in the Coverage pane of the Unit Test Sessions window. The pane displays the code coverage tree of the whole solution. You can also switch to the hot spot view by clicking Hot Spots on the toolbar.

Unit Test Sessions window

Different ways of exploring coverage results are described in the Working with Coverage Results section.

Customizing execution process

When tests in your project use (sometimes indirectly or implicitly) an assembly based on CLR2 and your project already targets CLR4, errors may occur during test execution. To avoid such situation, specify explicitly what CLR should be used.

To specify default CLR version

  1. On the main menu, choose ReSharper | Options. The Options dialog box opens.
  2. On the left pane of the dialog box, click Tools, then click Unit Testing .
  3. Specify a version using the Default .NET Framework version drop-down list. Click one of the following:
    • Automatic based on test project's target framework
    • Force tests to use CLR 2.0
    • Force tests to use CLR 4.0
    • Force tests to use CLR 4.5
  4. Click Save to apply the modifications and let dotCover choose where to save them, or save the modifications to a specific settings layer using the Save To drop-down list. For more information, see Managing and Sharing DotCover Settings.

This setting affects tests running under NUnit, XUnit and MSpec test frameworks. It has no effect on tests running under MsTest yet.

Sometimes it's also necessary to run tests using different architecture. You can specify once what platform to use and run all tests on it.

To set default platform architecture

  1. On the main menu, choose ReSharper | Options. The Options dialog box opens.
  2. On the left pane of the dialog box, click Tools, then Unit Testing.
  3. Specify platform architecture using the Default platform architecture drop-down list. Click one of the following:
    • Automatic based on test project's target platform
    • Force tests to run 32-bit process
    • Force tests to run 64-bit process
  4. Click Save to apply the modifications and let dotCover choose where to save them, or save the modifications to a specific settings layer using the Save To drop-down list. For more information, see Managing and Sharing DotCover Settings.
Last modified: 15 September 2015