Read more

The Self-Contained Test

Henning Koch
June 02, 2020Software engineer at makandra GmbH

One of the earliest pieces of wisdom we are given as programmers is to not write duplicate code: Don’t Repeat Yourself (or DRY if you prefer). Identical blocks of code to set up a test sure does look like repetition, so we extract it into a before block.

This is a mistake for tests.

The article explains about how sharing setup between examples make test files harder to read and evolve.

Illustration online protection

Rails professionals since 2007

Our laser focus on a single technology has made us a leader in this space. Need help?

  • We build a solid first version of your product
  • We train your development team
  • We rescue your project in trouble
Read more Show archive.org snapshot

A related frustration I have is working on ultra-DRY & betterspecs-like test files where shared setup has worked for all existing tests, but won't work for the test I need to add. I now need to refactor a huge file to add a small test.

Posted by Henning Koch to makandra dev (2020-06-02 09:16)