Learning to test your Ruby and Rails code can be tough. Even after you’ve been through blog posts and tutorials, screencasts and demo apps, you might find yourself feeling more lost than ever.
Ruby and Rails developers emphasize testing for good reasons, and you want to get on board, but even so, it can be damn hard to learn. You just want to write tests that tell you when you’re breaking something, run fast, and guide you in your work.
If you want to use even the most simple tool effectively, you need to know how to hold it. That’s why I’m writing The Minitest Cookbook - to help Ruby and Rails developers at all skill levels master the techniques they need to write clear, maintainable tests and help others to do the same. That process begins with a set of fundamentals where you’ll learn how to:
Once you’ve covered the basics and your feel you’re ready to move to the next level, we’ve got you covered, and so does Minitest. Because even though it’s compact, Minitest is also super flexible and ready to test whatever sort of Ruby code you want to throw at it. It’s based around a simple architecture and supports customizations via plugins, so you’ll be able to trick out your testing stack with third-party gems from a large and growing ecosystem of plugins. Later sections of the book will deal with advanced topics on a deeper level including how to:
Minitest is a full-featured framework for automated testing that supports both assertion-style and spec-style tests along with basic mocking, performance benchmarking, parallelization, and a simple plugin architecture. All this in around 1500 lines of code compared to over 12,000 for RSpec.
Keeping things simple is the whole point, and it’s one major reason why a lot of developers have been drawn to Minitest. It takes a restrained approach by providing developers with a minimal set of standard assertions and expectations that they can use to test their code or build on with their own creations. For you the developer, that means:
You’ve heard that good things come in small packages. This is what they were talking about.