XP Day 2006 - Are your tests really driving your development?
Are your tests really driving your development?
I won’t write much about this because should this be presented again and you attend knowing too much about it, it will, I think, spoil it a bit - but if you do get a chance to see this do, Nat and Steve very effectively make their point.
So, hopefully, without giving things away…
Do your tests really communicate their intent?
- don’t use magic numbers in your tests just as you wouldn’t in your production code
- consider creating value types where you might typically use primitive types - a parameter to a method of type PhoneNumber rather than just a simple String conveys far more information, even if the PhoneNumber class is just a very simple wrapper around a String
- a comment here and there can make a big difference
- where a method under test is returning a numerical result based on values passed to the method, express the expected result in terms of the values passed to the method, e.g.
assertEquals(2+2, billingService.caclculateCharge(2,2))rather thanassertEquals(4, billingService.caclculateCharge(2,2))