Skip to content

Instantly share code, notes, and snippets.

@kaineer
Created April 17, 2012 05:23
Show Gist options
  • Select an option

  • Save kaineer/2403677 to your computer and use it in GitHub Desktop.

Select an option

Save kaineer/2403677 to your computer and use it in GitHub Desktop.

http://37signals.com/svn/posts/3159-testing-like-the-tsa

Seven don'ts of testing

But while all that nuance might have a place in a two-hour dinner conversation with enlightened participants, not so much in a blog post. So let me firebomb the debate with the following list of nuance-less opinions about testing your typical Rails application:

  1. Don’t aim for 100% coverage.
  2. Code-to-test ratios above 1:2 is a smell, above 1:3 is a stink.
  3. You’re probably doing it wrong if testing is taking more than 1/3 of your time. You’re definitely doing it wrong if it’s taking up more than half.
  4. Don’t test standard Active Record associations, validations, or scopes.
  5. Reserve integration testing for issues arising from the integration of separate elements (aka don’t integration test things that can be unit tested instead).
  6. Don’t use Cucumber unless you live in the magic kingdom of non-programmers-writing-tests (and send me a bottle of fairy dust if you’re there!)
  7. Don’t force yourself to test-first every controller, model, and view (my ratio is typically 20% test-first, 80% test-after).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment