Rider Help

Executing Tests and Analyzing Results

Rider provides several ways to execute unit tests. Whichever way you choose, execution progress, results, and output are displayed in session tabs of the Unit Tests window.

Different ways of running and debugging unit tests

There are following ways to run or debug 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 are existing unit test sessions, you can run or debug some or all tests in a session:
    • Select tests that you want to execute in the session tab of the Unit Tests window and click Run Unit Tests /help/img/dotnet/2017.2/ThemedIcon.RunTest.Screen.[Gray].png / Debug Unit Tests /help/img/dotnet/2017.2/ThemedIcon.Debug.Screen.[Gray].png on the toolbar or press Ctrl+U, R / Ctrl+U, D.
    • To run all tests in the session, click Run All Tests /help/img/dotnet/2017.2/ThemedIcon.RunAll.Screen.[Gray].png on the toolbar or alternatively, choose Tools | Unit Tests | Run Current Session in the main menu or press Ctrl+U, Y.

As tests are running in a unit test session, the Stop Execution /help/img/dotnet/2017.2/ThemedIcon.StopTest.Screen.[Gray].png button becomes active. You can click this button to abort execution 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 always re-run the tests that you executed last by pressing Ctrl+U, U or choosing Tools | Unit Tests | Repeat Previous Run in the menu.

Run configurations for test sessions

Rider automatically creates a new run configuration for each test session. The created run configuration stays synchronized with the corresponding session until you remove the session.

Analysing execution results and output

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

/help/img/rider/2017.1/unit_test_sessions.png

The output pane (which you can place on the right or on the bottom using the Toggle output position /help/img/rider/2017.1/icon_toggle_output_position.png button on the toolbar) displays output of the selected test. If the test is failed, Rider 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.

By default, Rider 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 Build, Execution, Deployment | Unit Testing page of Rider settings (Ctrl+Alt+S).

On the status bar, you can see the total number of tests in the session as well as number of tests in different states:

Unit test filters
By default, tests in all states are shown, but you can click the corresponding icons to filter tests by their state. Status of each test in the Unit Test Sessions window is displayed with one of the following icons:

  • /help/img/dotnet/2017.2/ThemedIcon.RunningTest.Screen.[Gray].png — the unit test is currently executing.
  • /help/img/dotnet/2017.2/ThemedIcon.TestPending.Screen.[Gray].png — the unit test is scheduled for execution in the current run.
  • /help/img/dotnet/2017.2/ThemedIcon.StatusUnknown.Screen.[Gray].png — the unit test was not executed.
  • /help/img/dotnet/2017.2/ThemedIcon.Success.Screen.[Gray].png — the unit test passed in the lats test run.
  • /help/img/dotnet/2017.2/ThemedIcon.Error.Screen.[Gray].png — the unit test failed in the lats test run.
  • /help/img/dotnet/2017.2/ThemedIcon.Ignore.Screen.[Gray].png — the unit test was ignored in the last test run. Either it has the corresponding attribute (e.g. Ignore for NUnit tests) or it is included in a category that is ignored in Rider settings.
  • /help/img/dotnet/2017.2/ThemedIcon.StatusAborted.Screen.[Gray].png — the unit test was aborted in the last test run.
  • /help/img/dotnet/2017.2/ThemedIcon.StatusInconclusive.Screen.[Gray].png — the unit test was started but Rider could not read the the test runner output. This could be a sign of an error occurring in the test runner.

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

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

Last modified: 11 October 2017