[LRUG] A question on DRYness on testing methods that get / set state
Anthony Green
anthony.green at bbc.co.uk
Tue Nov 22 10:02:18 PST 2011
On 22 Nov 2011, at 11:23, Tim Cowlishaw wrote:
> I guess this is a bit of a tradeoff, but I'd be curious to know - how
> do you guys write tests for methods that get or set state? is there a
> better way than the above?
Spec behaviour, not implementation. I'd have a single example that
covers the behaviour "when I put a value, get should return that value".
Cheers,
-Tom
+1
A colleague recently ran an Object Calisthenics* Dojo and we came to the
same conclusions.
Removing direct access to state pushes you to think more about behaviour.
*
http://www.markhneedham.com/blog/2008/11/06/object-calisthenics-first-thoughts/
--
Anthony Green
iPlayer Desktop
BBC Future Media
More information about the Chat
mailing list