Minitest Rails Tutorial
Test Rails apps with Minitest, not guesswork
Learn automated testing step by step, from CRUD to models, fixtures, system tests, mailers, jobs, and CI. Minitest, fixtures, and Rails defaults the whole way.
Start here in three steps
You don't have to read everything today. Follow this path and you'll have a real test running in your own app.
-
Step 1
See why Minitest fits Rails
Read the introduction: who this is for, how the Recipes app grows, and why you won't need to hunt for a second test stack.
-
Step 2
Set up the Recipes app
Spin up the sample app with Minitest and system tests wired the way later chapters expect.
-
Step 3
Write your first automated test
Turn a scenario into a failing test, make it pass, and build the habit of green before you commit.
What you will have after the first three chapters
Not theory for its own sake. Each step leaves you with something you can run, show a teammate, or commit to git.
-
After step 1
You know the lay of the land
Why Minitest is the Rails default, how the Recipes app grows, and what each kind of test is for.
-
After step 2
Your machine runs the suite
A fresh Recipes app, system test gems wired for Rails 8, and green output from `bin/rails test:all`.
-
After step 3
You wrote tests that fail, then pass
A model validation test, HTTP tests for list and create, and one browser smoke check you can explain in plain English.
Every topic, in order
The tutorial has 22 chapters covering models, fixtures, system tests, auth, mailers, jobs, external APIs, and CI. Jump in anywhere once you know the basics, or follow the list top to bottom.
Open the chapter list