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.
In this topic:
- Different ways of executing and covering unit tests
- Analysing execution results and output
- Analysing coverage results
- Customizing execution process
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 / Debug Unit Tests / Cover Unit Tests 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 or Cover All Tests on the toolbar or alternatively, choose or 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 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 Stop Execution button becomes active. You can click this button to abort execution or coverage analysis of the tests. 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 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.
Analysing execution results and output
When the execution is over, the results are visualized in the Unit Test Sessions window.
The output pane (which you can place on the right or on the bottom using the Show Output button on the toolbar) displays output of the selected test. If the test is failed, dotCover also adds short information on the failure and/or displays the stack trace of an exception. You can use clickable links in the output pane to navigate directly to types and methods involved with the failure. If the output displays a link to a file that does not belong to the solution, you can click this link to open the file in an external application associated with the corresponding file type or Ctrl - click to open it in Visual Studio.
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:
- - the unit test is currently executing.
- - the unit test is scheduled for execution in the current run.
- - the unit test was not executed.
- - the unit test passed in the lats test run.
- - the unit test failed in the lats test run.
- the unit test was ignored in the last test run.
Either it has the corresponding attribute (e.g.
Ignorefor NUnit tests) or it is included in a category that is ignored in dotCover settings.
- - 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 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.
Different ways of exploring coverage results are described in the Working with Coverage Results section.
Customizing 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 options page. This preference affects tests running under NUnit, XUnit and MSpec test frameworks. It has no effect on tests running under MsTest yet.
If necessary, you can override these settings for specific unit test session using the Options selector on the toolbar.