RustRover 2024.1 Help

Doctests

The examples you provide in documentation can be turned into tests and included in test runs. The practice is referred to as documentation testing. It helps keep documentation up to date with your code. You can find out more about doctests in the rustdoc book.

Running doctests

RustRover automatically detects doctests. You can run them using the methods described below.

Moreover, since doctests are classified as tests, they are included in test runs. For ways to launch tests, refer to the Run tests page.

Run a doctest

  • To run a specific test, click in the gutter next to the doctest entry:

    Gutter menu for tests
  • To run all doctests in the module/project, open the Cargo Run Anything popup (press Ctrl twice) and specify the cargo test --doc command with additional arguments if required.

Doctest configuration

When you run doctests using one of the methods listed above, the IDE automatically creates a configuration and saves it for future use. To modify the current configuration, click the three dots icon, select Modify Run Configuration, and make the adjustments in the Edit Run Configuration dialog.

Modify run configuration for a doctest

You can also create a doctest configuration manually: follow the steps for creating a test configuration and specify the cargo test --doc command with additional arguments if required.

Viewing doctest results

Doctest results appear in the Run tool window, together with the results of regular tests. Learn more about manipulating test results on the Explore test results page.

Test results tab
Last modified: 24 April 2024