Writing Tests To Be Read

*
Proposal
Short Form
Intermediate

Excerpt

Good unit tests can help ensure that your code doesn't break; Great unit tests can teach people how to use it. In this session, you'll learn some tips for making tests readable enough that developers consult them as documentation.

Description

Good unit tests can help ensure that your code doesn’t break; Great unit tests can teach people how to use it. In this session, you’ll learn some tips for making clear, readable tests. The session will cover three general areas, with copious (but brief!) code examples:

  1. Keeping Out Clutter: Techniques for keeping tests focused on their core topic, and leaving out or hiding details that don’t matter.
  2. Putting It In Context: Techniques for using naming patterns and test structure to emphasize the problem domain of your code, rather than the mechanics of test setup.
  3. Telling a Story: Techniques for organizing larger groups of tests to tell developers what they most need to know.

Throughout the session, there will be a focus on short, memorable advice, and on realistic code examples.

Tags

unit testing, tdd, documentation

Speaking experience

I've spoken at the Agile Conference in 2010 and 2012, at Agile Games in Boston in 2012, and several times at local groups around Boston. Alas, none of these talks were recorded.

I've given variations on this talk to development teams at Cyrus, where I work, but I haven't previously given it in public.

Speaker