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?
What's in the book
The different kinds of Rails tests