Executing Tests and Analyzing Results
JetBrains Rider provides several ways to execute unit tests. Whichever way you choose, execution progress, test results, and output are displayed in the Unit Tests window, coverage results are shown in the Unit Test Coverage window.
Before running coverage analysis or performance profiling, 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 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 / Debug Unit Tests on the toolbar or press Ctrl+U, R / Ctrl+U, D.
To continuously run selected tests in the session until one of the tests fails, choose Repeat Tests Until Failure from the session's context menu, or from the main menu.
As tests are running in a unit test session, the Stop Execution 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.
Run configurations for test sessions
JetBrains 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.
The output pane (which you can place on the right or on the bottom using the Toggle output position button on the toolbar) displays output of the selected test. If the test is failed, JetBrains 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, JetBrains 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 checkbox on the page of JetBrains 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: 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:
— 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.
— the unit test was aborted in the last test run.
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.
The corresponding icons above the test session tree show how many tests are in each of the states. The icon shows the total number of tests in the session.
Using these icons, you can filter the tree so that only tests in the corresponding status are displayed.
When your focus is in the Unit Tests window, you can use simplified shortcuts for unit testing actions. For example, you can use Ctrl+D instead of Ctrl+U, D for debugging selected tests. Here is the full list of extra shortcuts that work in the Unit Tests window:
Shift+Enter — Run Selected Tests
Ctrl+D — Debug Selected Tests
Ctrl+Y — Run Current Session
Ctrl+F — Rerun Failed Tests
Shift+Alt+Insert — Create New Session
Ctrl+Alt+Insert — Append Selected Tests to Session
Delete — Remove Selected Tests
Ctrl+L — Run All Tests from Solution
Studying execution log
Unit Tests window includes test execution log that lets you separate problems related to test execution process from unit tests results.
You will normally need to check execution log if some of your tests have the 'Inconclusive' state after execution, which could be a sign of an error occurring in the test runner.
To check the execution log, click Launch on the Unit Tests window toolbar and choose Show Last Launch Log.
If the test execution ends with a test runner exception, you will see a link to the latest log file.