Chapter 7. Testing Tools

In this book, I've put testing front and center for the simple reason that I believe that automated testing is a critically important method for ensuring both code quality and long-term code maintainability. So far, I've focused on Ruby's standard Test::Unit structure as the primary tool in the testing toolkit. And while Test::Unit is a very important part of automated testing, it's far from the only tool you should be using to ensure that your Rails application is fully and completely tested.

In this chapter, you'll fill out your toolkit a bit and examine why each new tool is vital to your being a test-driven developer. You'll see how to measure the amount of code that is touched by your tests, and how you can use mock objects to improve your code and reach otherwise-difficult-to-cover parts of the code. Then you'll look at some tools for behavior-driven testing, a technique that uses mock objects extensively. Finally, you'll see a way to separate controller and view tests in Rails.

Get Professional Ruby on Rails™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.