Run tests
Run the selected test or test folder: CtrlShiftF10
Stop the current test session: CtrlF2
To run all the tests in your Cargo project, do one of the following:
On the main toolbar, select the Test [project_name] configuration in the switcher and click
.
tip
The Test [project_name] configuration is created automatically when you open a project for the first time. It runs the
cargo test --workspace
command. You can edit this configuration like any other in Run | Edit Configurations.Press Ctrl twice to invoke the Run Anything popup. Type the
cargo test --workspace
command and press Enter.Open the Cargo tool window (View | Tool Windows | Cargo). Click the
button, type
test --workspace
, and press Enter.
If your tests don't require any specific actions before start, and you don't want to configure additional options, such as code coverage, you can run them by using the following options:
Place the caret at the test file to run all tests in that file, or at the test method, and press CtrlShiftF10. Alternatively, click the
gutter icon next to the test method and select Run '<test name>' from the list.
Press Ctrl twice to open the Run Anything popup and specify the
cargo test
command with additional arguments if required.Double-click the test target in the Cargo tool window (View | Tool Windows | Cargo).
To run all tests in a folder, select this folder in the Project tool window and press CtrlShiftF10 or select Run Tests in 'folder' from the context menu.
When you run a test, RustRover creates a temporary run configuration. You can save temporary run configurations, change their settings, share them with other members of your team. For more information, refer to Run/debug configurations.
Use the Run widget on the main toolbar to select the configuration you want to run.
Click
or press ShiftF10.
Open the Run/Debug Configuration dialog by doing one of the following:
From the configuration switcher on the main toolbar, select Run | Edit Configurations.
Go to Run | Edit Configurations.
Press AltShiftF10 and select Edit Configuration from the context menu.
Click
on the toolbar and select Cargo.
Name your configuration (or leave the default name).
In the Command field, type the Cargo command:
test
+ extra arguments if needed.Click Apply and close the Run/Debug Configurations dialog.
After RustRover finishes running your tests, it shows the results in the Run tool window on the tab for that run configuration. For more information about analyzing test results, refer to Explore test results.
![Test runner in the Run tool window Test runner in the Run tool window](https://resources.jetbrains.com/help/img/idea/2024.3/ri_test_runner_tab.png)
The console on the right shows the output of the current test session. The test results toolbar located above the list of test results provides you with several helpful options.
![the test results toolbar the test results toolbar](https://resources.jetbrains.com/help/img/idea/2024.3/ri_testResultsToolbar.png)
Use the following options on the test results toolbar of the tab for the run configuration:
Click
or press CtrlF2 to terminate the process immediately.
Click
to terminate the process gracefully, allowing shutdown hooks to run.
![Stop running tests Stop running tests](https://resources.jetbrains.com/help/img/idea/2024.3/ri_stop_running_tests.png)
Right-click a test on the tab for the run configuration in the Run tool window and select Run 'test name'.
![Rerun a single test Rerun a single test](https://resources.jetbrains.com/help/img/idea/2024.3/ri_rerun_one_test.png)
Click
on the test results toolbar or press CtrlF5 to rerun all tests in a session.
![Rerun all session tests Rerun all session tests](https://resources.jetbrains.com/help/img/idea/2024.3/ri_all_session_tests.png)
In RustRover, you can enable the autotest-like runner: any test in the current run configuration restarts automatically after you change the related source code.
Click
Rerun Automatically on the test results toolbar to enable the autotest-like runner.
To start running or debugging a test, you can use the main toolbar or a context menu in the Project tool window or in the editor:
Use the main toolbar:
Select the necessary run/debug configuration from the list on the main toolbar.
Press AltShiftF10 to see the list of available run configurations or AltShiftF9 for debug configurations.
Click Run
or Debug
to the right of the list. Alternatively, select Run | Run ShiftF10 or Run | Debug ShiftF9 from the main menu.
Use a context menu:
Right-click a test class in the Project tool window or open it in the editor, and right-click the background. From the context menu, select Run <class name> or Debug....
For a test method, open the class in the editor and right click anywhere in the method. The context menu suggests the command Run / Debug <method name>.
Thanks for your feedback!