dotCover 2024.2 Help

Execute tests

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

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

Different ways to run, debug or cover unit tests

Start test execution

  • 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 are existing unit test sessions, you can run, debug or cover some or all tests in a session:

    • Select tests that you want to execute in the Unit Test Sessions window and click Run Unit Tests Run Unit Tests Control+T R/ Debug Unit Tests Debug Unit Tests Control+T D on the toolbar.

    • To run all tests in the session, click Run Current Session Run Current Session Control+T Y on the toolbar or alternatively, choose ReSharper | Unit Tests | Run Current Session from the main menu.

    • To cover tests in the selected node of the session, right-click this node and choose Cover Unit Tests Cover Unit Tests Control+T H.

    • To keep automatically starting and running selected tests until one of the tests fails, expand the selector at the Run Unit Tests Run Unit Tests Control+T R button and choose Run Unit Tests Until Fail.

As tests are running in a unit test session, the execution progress is shown in the status bar under the toolbar of the Unit Test Sessions window and the progress icon is displayed next to the currently executing test. You can run multiple unit test sessions simultaneously. However, when you debug tests, only one test session can be executed at a time.

If necessary, you can enable the Track Running Test ThemedIcon.TrackRun.Screen.(Gray).png 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 ThemedIcon.ScrollToBottom.Screen.(Gray).png option to follow output of tests as they are running.

Stop test execution

  1. Click Stop Execution ThemedIcon.StopTest.Screen.(Gray).png on the toolbar to abort execution or coverage analysis of the tests.

  2. dotCover will send the signal to the test runner to stop execution. Depending on the test framework, the execution can be aborted immediately, or the runner may try to finish the current test and stop after that.

  3. If the test runner continues executing the current test, the Stop Execution icon changes to ThemedIcon.Abort.Screen.(Gray).png. You can click it again to force quit the test runner process.

If necessary, you can always repeat execution or coverage analysis of the tests that you executed last by clicking Repeat Previous Run ThemedIcon.Rerun.Screen.(Gray).png on the toolbar, pressing Control+T T or choosing ReSharper | Unit Tests | Repeat Previous Run from the menu.

Apply coverage filters

dotCover supports two types of coverage filters that let you exclude code from coverage analysis: runtime filters (applied during a coverage session) and filters of coverage results. Learn more

Customize execution process

By default, dotCover uses unit test project settings to define which .NET Framework version and processor architecture should be used when executing tests.

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. You can avoid such situation, by specifying explicitly what CLR (.NET Framework) should be used. To do so, use the Default .NET Framework version selector on the Tools | Unit Testing page of dotCover options Alt+R, O. This preference affects tests running under NUnit, XUnit and MSpec test frameworks. It has no effect on tests running under MSTest yet.

You can also change the platform architecture (32-bit or 64-bit) using the Default platform architecture selector on that options page.

If necessary, you can override these settings for specific unit test session using the Options selector on the toolbar.

Last modified: 01 October 2024