On this page:
IntelliJ IDEA helps you write tests using the MiniTest testing framework. MiniTest comes bundled with Ruby 1.9.x, but we suggest to use minitest, as a more up-to-date version.
Before you start, make sure that:
- minitest is downloaded and installed on your computer.
IntelliJ IDEA supports
minitestversions higher than 3.1.0
- minitest-reporters, version 0.5.0 or higher, is downloaded and installed on your computer. This gem is required for integration with IntelliJ IDEA test runner.
minitest>= 5.0.0, minitest-reporters gem is not required.
For Windows, win32Console, version '1.3.0' is downloaded and installed.
- The gems should be properly attached to your project. For example, if you use the Bundler for managing gems, the required gems should be added to the
Gemfileof your project.
For example, the
Gemfilecan contain the following code:
group :test do if RUBY_PLATFORM =~ /(win32|w32)/ gem "win32console", '1.3.0' end gem "minitest" gem 'minitest-reporters', '>= 0.5.0' gem 'cucumber-rails' end
- Depending on the version of
minitest-reportersgem, one of the following code fragments is added to your tests (if you are working with a Rails application, it is better accomplished with
Version 0.8.0 and higher
require 'minitest/reporters' MiniTest::Reporters.use!
- Older versions
require 'minitest/reporters' MiniTest::Unit.runner = MiniTest::SuiteRunner.new if ENV["RM_INFO"] || ENV["TEAMCITY_VERSION"] MiniTest::Unit.runner.reporters << MiniTest::Reporters::RubyMineReporter.new elsif ENV['TM_PID'] MiniTest::Unit.runner.reporters << MiniTest::Reporters::RubyMateReporter.new else MiniTest::Unit.runner.reporters << MiniTest::Reporters::ProgressReporter.new end
The above code enables specific results reporter, which depends on the environment where tests have been launched: IntelliJ IDEA, TeamCity CI server, or TextMate text editor/ terminal. This approach is helpful, when you work in a mixed team that uses different IDEs, or text editors.
It is important to execute this code at the test initialization, before running the tests.
As mentioned before,
minitest-reporters gem is required for integration with IntelliJ IDEA for
minitest version lower than 5.0.0.
However, this gem is still essential for the higher versions of
minitest, if you want to see the test results in a tree view:
rather than as plain list:
It's important that the names of the
minitest files match the following patterns:
The test case classes should have suffix
FooTest < AcceptanceTest
This limitation is not related to
MiniTest, but rather is imposed by IntelliJ IDEA's code insight.