Question
After creating and launching a new .NET run configuration, unit tests do not start automatically. How can one launch unit tests in the project?
Answer
Rider works with unit test run configurations differently - it uses the Unit Test tool window that allows one to run/debug unit tests. One can start a new Unit Testing session using one of the following methods:
1. Running Tests from the Editor Gutter
- Open a C# file containing unit tests.
- Look for the icons in the editor gutter (the left margin next to line numbers). Rider automatically identifies test classes and methods. A green play button usually indicates test(s) are present.
- Click the play button
- A small context menu will appear. Select
RunorDebugdepending on whether one wants to execute the tests or step through them with the debugger
2. Running Tests from the Solution Explorer
- In the Solution Explorer window, navigate to the test project, a specific folder or a test file (
.cs) - Right-click on the desired item (project, folder, or file)
- In the context menu, look for the
Run Testsaction
This action will launch all discovered tests within the selected scope and display the results in the Unit Tests tool window.
3. Running Tests from the Unit Tests Tool Window
The Unit Tests tool window itself provides controls for running tests.
- Open the Unit Tests tool window:
- Go to View → Tool Windows → Unit Tests
- Rider will discover and list the tests found in the solution
- Select the target tests in the tree view
- Click the green "Run Unit Tests" play icon in the tool window's toolbar. Alternatively, right-click the selection and choose
Run Selected Tests.
This will start a new session in the same tool window, updating the view with the execution progress and results for the selected tests.
4. Running Tests via Keyboard Shortcuts
Rider provides default keyboard shortcuts for common testing actions. While shortcuts can vary based on the chosen keymap (e.g., Visual Studio, Rider default), common ones include:
- Run Unit Tests (all discoverable tests)
- Run context (test at caret/selection)
The shortcuts can be configured under (Settings | Keymap).
Comments
0 comments
Please sign in to leave a comment.