RubyMine 2021.2 Help

Run tests

Quick way

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 class to run all tests in that class, or at the test method, and press Ctrl+Shift+F10. Alternatively, click the gutter icon next to the test class or test method.

    The gutter icon changes depending on the state of your test:

    • The the Run button gutter icon marks new tests.

    • The the Run test icon gutter icon marks successful tests.

    • The the Rerun the Run button gutter icon marks failed tests.

    Run a specific test from the editor
  • You can run all tests in one or several files or a folder at once. Select the required folder or test files and press Ctrl+Shift+F10. Alternatively, call the context menu and select Run 'All tests in <directory name>' or Run 'All specs in <directory name>' depending on the testing framework in use.

    Run all tests in a directory

Customizable way

When you run a test, RubyMine creates a temporary run configuration. You can save temporary run configurations, change their settings (for example, pass task arguments, specify environment variables, and so on), share them with other members of your team.

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

  2. From the list on the main toolbar, select the configuration you want to run.

  3. Click the Run button or press Shift+F10.

    Running a run/debug configuration for tests

After RubyMine finishes running your tests, it shows the results in the Run tool window on the Test Runner tab. For more information on how to analyze test results, refer to Explore test results.

Run tests using Rake tasks

To run tests using a Rake task, do the following:

  1. From the main menu, select Tools | Run Rake Task Ctrl+Alt+R.

  2. In the invoked popup, start typing the name of a Rake task that runs tests, for example, rake test or rake spec:controllers.

  3. Select the desired Rake task from the list and press Enter.

Run tests before commit

When you want to check that your changes wouldn't break the code before committing them, you can do that by running tests as a pre-commit check.

Set up test configuration

  1. Open the Commit tool window as described in the following topics:

  2. Click Show Commit Options the Settings button. In the menu, click Choose configuration near Run Tests and select which configuration you want to run.

    Pre-commit checks menu

After you have set up the test configuration, the specified tests will run every time you make a commit.

Non-modal commit dialog running a test

Stop tests

Use the following options on the Run toolbar of the Test Runner tab:

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

Stop running tests

Rerun tests

Rerun a single test

  • Right-click a test on the Test Runner tab of the Run tool window and select Run 'test name'.

Rerun all tests in a session

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

Rerun failed tests

  • Click the Rerun Failed Tests button on the Run toolbar to rerun only failed tests.

    Hold Shift and click the Rerun Failed Tests button to choose whether you want to Run the tests again or Debug them.

Rerun tests automatically

In RubyMine, you can enable the autotest-like runner: any test in the current run configuration restarts automatically after you change the related source code.

  • Click Toggle auto-test Toggle auto-test on the Run toolbar to enable the autotest-like runner.

    The Toggle Auto-Test option

Debug failed tests

If you don't know why a test fails, you can debug it.

  1. In the editor, click the gutter on the line where you want to set a breakpoint.

    There are different types of breakpoints that you can use depending on where you want to suspend the program. For more information, refer to Breakpoints.

  2. Right-click the the Rerun the Run button gutter icon next to the failed test and select Debug 'test name'.

    Debugging a failed test

    The test that has failed will be rerun in the debug mode. After that, the test will be suspended, allowing you to examine its current state.

    You can step through the test to analyze its execution in detail.

Last modified: 14 September 2021