Search⌘ K
AI Features

Minitest Setup

Explore how to effectively set up tests using Minitest in Rails applications. Understand the use of a single setup method, how to manage multiple setup scenarios with explicit method calls, and differences compared to RSpec. Learn to handle test data creation with factory_bot to maintain database associations for robust testing.

One of the clearest differences between the RSpec and Minitest ways is setting up different data for different tests. In RSpec, the describe method is used to enclose an arbitrary number of tests to give each group of tests a different setup. For example, our Project specs in spec/models/project_spec.rb file have three different groups, one without a task, one with a task, and one with a bunch of tasks.

Minitest setup

In Minitest, each class has one setup method.

...