Running Minitest

Rails provides some standard Rake tasks for running all or part of the test suite.

The one to use most of the time, which is not the Rails default, is rake test:all; it grabs any files ending with _test.rb in the test directory or any of its subdirectories and executes them through Minitest. For running a single file, Minitest and Rails use the syntax open rake test test/models/task_test.rb. For now we’ll assume we’re using rake test:all. In Chapter 15, ​Running Tests Faster and Running Faster Tests​, we’ll cover better ways to focus test execution.

When you run rake test:all, the Rake task identifies any files matching the pattern test/**/*_test.rb and passes them all to Minitest. (The related task rake test:all:db ...

Get Rails 4 Test Prescriptions now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.