To some degree I envy programmers for their clear guidelines. One of these set of these guidelines is well-written in Robert Martin’s book Clean Code – A Handbook of Agile Software Craftsmanship. (Personally, I hope that Kurt Häusler will review it this Software Craftsmanship week on his blog.) So, today I decided to write about Clean Tests, and what a book on the topic should cover.
Rather than focusing this discussion on the ever-lasting consideration of automated or manual tests, test cases or exploratory approaches, let’s take a closer look at the meta-level. What’s a good test? While watching Cem Kaner’s videos on Black-box software testing, I noticed something that I had already seen somewhere else. In the session on bug advocacy he speaks about how to report a bug in the system well. A bug report should be clear to the degree that the steps to reproduce the bug are reported to the individual programmer who gets the bug assigned. He expresses that the reproducing steps should be as minimal as possible, alongside with the focus on the intention of the user or stakeholder who might get bugged by the system behavior. Now, this simple guideline holds for automated tests at the unit level, and at the system level, as well as for any manual test. Taking the idea one step further, a clean test focuses on the intentions of a (reasonable) user of the software. This is our first guideline.
Letting my mind wander I noticed that I had read recently about user intentions and goals. Writing Effective Use Cases from Alistair Cockburn describes the topic in sufficient detail. Interestingly considering use cases and requirements specifications in general, there are many more parallels that also hold for good tests. The second guideline can be directly derived from use cases. A use case should focus on what the actual goal of a reasonable user of the software is.
This also holds for a good test. A clean test focuses on what a reasonable user wants to achieve – rather than how.
So, this is our stepping stone for clean tests. I really hope to add some more over time, maybe influenced by some of the responses to this initial description.
One thought on “Software Craftsmanship week: Clean Tests”