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

The More Detailed Five: SWIFT Tests

I like to use five criteria to evaluate test quality. I’ve even managed to turn them into an acronym that is only slightly contrived: SWIFT.

  • Straightforward

  • Well defined

  • Independent

  • Fast

  • Truthful

Let’s explore those in more detail.

[S]traightforward

A test is straightforward if its purpose is immediately understandable.

Straightforwardness in testing goes beyond just having clear code. A straightforward test is also clear about how it fits into the larger test suite. Every test should have a point: it should test something different from the other tests, and that purpose should be easy to discern from reading the test.

Here is a test that is not straightforward:

 
## Don't do this
 
it ​"should add to 37" ...

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