RustRover 2024.3 Help

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 the Run icon.

    Selecting the default test project run/debug configuration
  • 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 the Run Cargo Command icon 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.

    Running a test using the gutter icon
  • Press Ctrl twice to open the Run Anything popup and specify the cargo test command with additional arguments if required.

    Running tests through the Run Anything popup
  • Double-click the test target in the Cargo tool window (View | Tool Windows | Cargo).

    Running a test target from 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.

    Run all tests in a directory

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.

  1. Create a new run configuration or save a temporary one.

  2. Use the Run widget on the main toolbar to select the configuration you want to run.

    Selecting a test configuration
  3. Click or press Shift+F10.

    Running a run/debug configuration for tests

Create a test configuration

  1. 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 Alt+Shift+F10 and select Edit Configuration from the context menu.

    Editing a test configuration
  2. Click Add New Configuration on the toolbar and select Cargo.

  3. Name your configuration (or leave the default name).

  4. In the Command field, type the Cargo command: test + extra arguments if needed.

  5. 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

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

Stop tests

Use the following options on the test results toolbar of the tab for the run configuration:

  • Click the Stop button or press Ctrl+F2 to terminate the process immediately.

  • Click the Exit button to terminate the process gracefully, allowing shutdown hooks to run.

Stop running tests

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 a single test

Rerun all tests in a session

  • Click the Rerun button on the test results toolbar or press Ctrl+F5 to rerun all tests in a session.

Rerun all session tests

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 Rerun Automatically on the test results toolbar to enable the autotest-like runner.

    Rerun automatically option

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:

    1. 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.

    2. Click Run Run or Debug Debug to the right of the list. Alternatively, select Run | Run Shift+F10 or Run | Debug 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>.

Last modified: 12 November 2024