All Books! All Books

The Minitest Cookbook

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

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:

  • Write tests using both assertions and specs
  • Structure your tests for clarity and confidence
  • Validate your code with assertions and expectations
  • Use mocks, stubs, and other kinds of test doubles
  • Effectively manage test data
  • Share common code between tests
  • Run one test case or your whole suite

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:

  • Test your Rails applications from top to bottom
  • Customize your test reports with better, more actionable information
  • Cover hard-to-reach code that you couldn’t test before
  • Write custom assertions and expectations specifically for your application
  • Build and release your own framework extensions