If you've tried to learn Rails testing, maybe you've been stuck on these common testing questions...
"What should I write tests for?"
You know you should be testing but you're not sure exactly what to test. The advice you've read doesn't seem to apply when the rubber meets the road.
How can I make testing a habitual part of my development workflow?
Maybe you conceptually understand how to write tests but you still aren't actually doing it. What's the difference between you and the people who write tests for all their code? Do they just have more discipline? What's the secret?
"What test framework should I use, MiniTest or RSpec?"
You know that MiniTest and RSpec are the two most popular testing frameworks for Rails, but you're not sure how to decide which one to use. There seem to be good (and strongly expressed!) arguments on both sides. How do you pick?
What level of test coverage do I need?
You've seen the tools that measure code coverage but you're not sure how much is really needed. 100%? 60%? 80%? Is there such a thing as too much testing?
Do I need to be doing TDD 100% of the time in order to be doing it "right"?
You've heard about test-driven development, and maybe you've even done a little TDD, but it's not clear how to do TDD all the time. Do you have to do TDD all the time in order to be a "real" tester? Is TDD even a good thing?
What are the various Rails testing tools and how do I use them?
Factory Bot, Faker, RSpec, VCR, WebMock... there are so many testing tools. What are they all for? Do you need them all?
Imagine what it would feel like to have really strong testing skills
You'd write tests as easily as you write regular code.
When you're comfortable with testing, you don't have to think hard about it. The tests just flow out. In fact, all your coding gets easier, because the tests you write help guide you forward.
You wouldn't have to force yourself to write tests because testing is just a habit.
To developers who are good at testing, writing tests isn't an extra chore. Writing tests isn't something they have to remember to do. It's just a normal part of the coding process. Furthermore, it's a fun and enjoyable part of the coding process.
You would choose your testing tools with confidence.
When you understand what the available testing tools are and why different teams choose different tools, it becomes easy to make the right choice for yourself. You can make the decision once and never worry about it again.
You would know how to do TDD and when to use it.
It would be 100% clear to you how to TDD any feature—IF you wanted to. And when you don't want to TDD a feature, you'll know why you're making that choice.
Introducing: the Complete Guide to Rails Testing
234 Pages, E-book Format
Contains the solutions to your testing problems
✅ What are the different kinds of Rails tests?
✅ What are all the Rails testing tools and how do I use them?
✅ Which testing framework should I use (RSpec or Minitest)?
✅ How can I make testing a habitual part of my development work?
✅ What level of test coverage should I shoot for?
✅ How do I add tests to an existing Rails project?
✅ Much more
What's in the book
The different kinds of Rails tests
There are several different types of RSpec tests you can use. I show which ones to use and which ones to skip.
The various Rails testing tools and how to use them
Covers RSpec, Factory Bot, Capybara, VCR and WebMock.
How to decide which testing framework to use
Explains how to decide between the two big testing frameworks, RSpec and MiniTest.
How to make testing a habit
It's not enough to know how to write tests, you actually have to do it. I show you how to make testing a habit.
What level of test coverage to shoot for
Shows what level of test coverage to shoot for (hint: it's not a number).
How to add tests to an existing Rails project
Adding tests to an existing Rails project is a whole different ballgame from testing a greenfield app. I show you how.
How to set up a new Rails project for testing
I show you exactly how I set up all my new Rails projects.
How to decide when to do test-driven development
Are you testing "wrong" if you don't do TDD? I show you my approach to test-driven development.
Installation, configuraiton, factory definitions, nested factories, traits, callbacks and transient attributes.
Ruby blocks, let and let! vs. instance variables, describe and context, RSpec's DSL.
When to write system specs, how to write system specs, a formula for writing system specs for most features.
What kinds of model specs to write and what kinds not to, the difference between testing implementation and behavior, much more.
What request specs are, the scenarios where request specs are useful vs. where they're not.
Mocks and Stubs
Test doubles, the difference between mocks and stubs, when to use mocks and stubs.
VCR and WebMock
Why to use VCR and WebMock, installation and configuration, how to use VCR and WebMock.