[LRUG] A question on DRYness on testing methods that get / set state
Graham Ashton
graham at effectif.com
Wed Nov 23 00:32:05 PST 2011
On 23 Nov 2011, at 08:10, 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.
Do you mean you'd test all those behaviours, irrespective of how you implement it?
I only ask as I just test things that I think might not work, in the context of how I've implemented it. i.e. My decisions are informed by my knowledge of the implementation.
So if we were using attr_* to implement the feature (I realise it's a contrived example) I'd skip the test entirely as I'd just be testing Ruby (which is pointless). If I wrote my own getter and setter and implemented them the same way as attr_* does it, I'd only need to test behaviour 2. Checking 1, 3 and 4 would introduce cruft.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20111123/1ad64c85/attachment-0003.html>
More information about the Chat
mailing list