Run tests
Run all tests in a project
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 .
Press Ctrl twice to invoke the Run Anything popup. Type the
cargo test --workspace
command and press Enter.Open the Cargo tool window ( ). Click the button, type
test --workspace
, and press Enter.
Run tests directly in a file or folder
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 Ctrl+Shift+F10. 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 ( ).
To run all tests in a folder, select this folder in the Project tool window and press Ctrl+Shift+F10 or select Run Tests in 'folder' from the context menu.
Customizable way (using a run/debug configuration)
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 Shift+F10.
Create a test configuration
Open the Run/Debug Configuration dialog by doing one of the following:
From the configuration switcher on the main toolbar, select
.Go to
.Press Alt+Shift+F10 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.
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.
Stop tests
Use the following options on the test results toolbar of the tab for the run configuration:
Click or press Ctrl+F2 to terminate the process immediately.
Click to terminate the process gracefully, allowing shutdown hooks to run.
Rerun tests
Rerun a single test
Right-click a test on the tab for the run configuration in the Run tool window and select Run 'test name'.
Rerun all tests in a session
Click on the test results toolbar or press Ctrl+F5 to rerun all tests in a session.
Rerun tests automatically
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.
Run or debug a test
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 Alt+Shift+F10 to see the list of available run configurations or Alt+Shift+F9 for debug configurations.
Click Run or Debug to the right of the list. Alternatively, select Shift+F10 or Shift+F9 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>.