O'Reilly logo

Rails 4 Test Prescriptions by Noel Rappin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Testing First Drives Design

Success with test-driven development starts with trusting the process. The classic process goes like this:

  1. Create a test. The test should be short and test for one thing in your code. The test should run automatically.

  2. Make sure the test fails. Verifying the test failure before you write code helps ensure that the test really does what you expect.

  3. Write the simplest code that could possibly make the test pass. Don’t worry about good code yet. Don’t look ahead. Sometimes, write just enough code to clear the current error.

  4. After the test passes, refactor to improve the code. Clean up duplication. Optimize. Create new abstractions. Refactoring is a key part of design, so don’t skip this. Remember to run the tests again ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required