Search⌘ K

Running Minitest

Explore the process of running Minitest in Rails to execute your tests efficiently. Understand how Minitest loads test files, runs test methods with setup and teardown blocks, and manages fixtures to ensure consistent test environments. This lesson helps you grasp the workflow of executing tests with Minitest commands and control fixture loading for better test management.

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

Minitest directories

The one to use most of the time, which is not the Rails default, is rails test (often bin/rails test, depending on how our bundle is set up). It grabs any files ending with _test.rb in the test directory or any of its subdirectories (except for system tests) and executes them through Minitest. Minitest and Rails use the syntax rails test test/models/task_test.rb for running a single file or directory. For now, let’s assume we’re using rails test. In the chapter “ ...