[LRUG] A question on DRYness on testing methods that get / set state

Tim Cowlishaw tim at timcowlishaw.co.uk
Thu Nov 24 01:41:41 PST 2011


On Wed, Nov 23, 2011 at 8:10 AM, Matthew Rudy Jacobs
<matthewrudyjacobs at gmail.com> wrote:
> You can structure the naming of your tests in an infinite number of ways
> but these are the behaviours I'd care about.
>
> If I don't PUT anything into the box, I GET nothing out.
> If I PUT something in the box I GET out the same thing
> If I PUT something in the box and try to GET it multiple times, I always GET
> the same thing
> If I PUT multiple things into the box, I only ever GET the most recent.

Aha! This is exactly my problem I think - testing *to* an interface
doesn't necessarily mean structuring your tests around that interface
- and that was what was causing the duplication. Thank you!

As an aside, this is a real eye-opener about what specific behaviours
I should be thinking about - I also like how it's very close to
quickcheck-style assertions of algebraic properties eg ("GET should be
idempotent"), but expressed in a friendlier way.

Thanks!

Tim



More information about the Chat mailing list