Early Access Program Features Learn RubyMine Testing Tutorials

Running Tests in RubyMine: Overview & Improvements

RubyMine comes with a testing suite for running RSpec, Minitest, Cucumber, and other tests based on your current context, and working with them in a friendly graphical user interface. Let’s see how it works in the following example.

Run Tests

Once your database and test environment are all set up, you can run all tests in your application, directory, or file, or even run any specific test. Simply navigate to the desired scope, and choose Run test(s)… from the context menu. Alternatively, use the keyboard shortcut Ctrl+Shift+R on Mac or Ctrl+Shift+F10 on Linux/Windows:

When you run a test in RubyMine for the first time, the IDE creates a temporary run configuration for it. You can access and edit it, or create a new test configuration in the Toolbar:

In the Run/Debug Configuration dialog, you can add additional Ruby arguments, environment variables, and other options to specify the way you want to run your tests:

As soon as you run a test, RubyMine opens the Run Tool Window where you can see the results and navigate to any of them by double-clicking the test icon. Alternatively, you can invoke the context menu and choose Jump to Source:

Some other options, such as sorting and exporting tests, are also available from the Run Tool Window.

Rerun Failed Tests

In the previous major release, we announced a useful ability to rerun only failed tests. This feature comes in handy when you’re debugging or fixing tests, and you want to rerun only the failed ones, instead or rerunning all of them. This takes just one click:

Test Gutters

RubyMine 2018.3 also adds a handy gutter at each test method. These gutters are visual anchors that show you every particular test that can be run in a file. They also help you run tests faster than from the context menu. Again, one click is all you need:

Finally, RubyMine provides a way to quickly navigate from a test subject, like a controller or a model, to its test, and back. To do so, go to Navigate | Test / Test Subject or press ⌘⇧T / Ctrl+Shift+T:

By the way, if a test file doesn’t exist, RubyMine will suggest creating one based on the test framework you are using, and will navigate to the newly created test file. Even if a gem for the desired test framework is missing in your app, the IDE will first install it, and then create the missing test file:

Get the latest RubyMine 2018.3 build to try this and all the other testing features. If you face any issues, please report them to our
bug tracker. Thanks!


Your RubyMine Team

Comments below can no longer be edited.

6 Responses to Running Tests in RubyMine: Overview & Improvements

  1. Avatar

    Wilson says:

    November 14, 2018

    Shift + Command + T is soooo useful. Thanks! I feel like I’m not using even 10% of the IDE’s power. Please do more posts like these.

    • Avatar

      Artem Sarkisov says:

      December 27, 2018

      Thank you, Wilson!

      I’m really looking forward to creating more posts like these. Some of them I already banded under the tag `learn`. You may find them useful as well, please see https://blog.jetbrains.com/ruby/tag/learn/

      • Avatar

        Wilson Silva says:

        December 27, 2018

        Perfect. Thank you, Artem. This is exactly what I’m looking for.

  2. Avatar

    Chris Mendla says:

    December 4, 2019

    Can you also navigate from code that is covered to the corresponding rspec test? I see how it works for tests but it doesn’t seem to work for rspec.



  3. Avatar

    Chris Mendla says:

    December 4, 2019

    I think you can disregard my previous comment. I would have sworn that didn’t work (code-rspec test) but now it appears to be working.


    • Avatar

      Artem Sarkisov says:

      December 5, 2019

      Let us know if this happens again!

Discover more