Your Tests Are Too DRY

By Nate Taylor

Elevator Pitch

The Don’t Repeat Yourself (DRY) principle is great, but using it while writing tests can cause pain and frustration. This talk looks at how to stay sane while not worrying about DRY tests.

Description

Have you ever struggled to add a new test case to an existing suite of tests? Ever added a value to the setup and seen several new failing tests? Does it often feel like you’re spending more time fighting against your tests than you are writing new, meaningful tests? All of these situations might be the result of having your tests be too DRY.

The Don’t Repeat Yourself (DRY) principle is widely accepted as a good practice in software development, but it doesn’t translate well to the test code you write. This talk will help equip you to write tests that are clear in what their intention is. As a result, you should experience less frustration adding a new test. All this without the need to spend a lot of time updating tests you’ve already written.

Notes

I’ve been writing unit tests for 8 years, and I’ve been doing TDD for the last 5. Over that time I’ve learned through experience some patterns to unit testing that make it easier to work with tests.

The examples will be given in JavaScript, but the principles apply to all unit testing.