Outside-in Testing

The process we’ll use to manage our Capybara tests is sometimes called outside-in testing—we start using Capybara to write a test from the outside and use that test to drive our unit tests. In the same way that TDD uses a failing unit test to drive code, outside-in testing uses a failing acceptance test (or a failing line in an acceptance test) to drive the creation of unit tests.

The process follows Figure 1, ​Outside-in testing​—we’re assuming the creation of a new user-facing feature in a Rails application.

images/outside_in.png
Figure 1. Outside-in testing

Let’s walk through the steps.

  1. Write the end-to-end test that shows a user ...

Get Rails 4 Test Prescriptions 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.