Posts

Showing posts with the label microtest

Making Data Relationships Obvious

When you are writing tests you end up using literals or hand-constructed data objects. However, using literals can obscure the meaning a little. Not horribly; most people can puzzle them out quickly enough, but you can make it easier on the reader. In most of these tests, the values are pretty much arbitrary, but the relationship between the values is essential. For instance, when checking that no bonus is given when sales is less than quota, I could state that sales is 10,000.00 and that the quota is 9,900.00.  Pretty much anyone could tell that the quota is less than sales here, right? But what if we made it really explicit?      double quota = 10000;      double sales = quota - 100; This is how I like to roll. For instance, in python:      event_date = datetime(2015,9,10)      later = event_date + timedelta(days=10)      earlier = event_date - timedelta(days=2) And how ...

TDD: more to know

The basics are well-known: Everyone knows the basic cycle of TDD. You should also know the improved Industrial Logic version of the TDD cycle . You have heard Uncle Bob's three rules . But there is so much more to know. I have been gathering little sound bites for you which may help you build your skills and knowledge. Please feel free to drop additional factoids or questions. I'm happy to explain any of these at length if you like. Here is my list: Your code has two parts: the part you have covered with TDD, and the part that requires you to use a debugger. Microtests are F.I.R.S.T.   (you cannot TDD after writing the code) Only microtests are appropriate for TDD; other tests are useful, but not for TDD. Microtests are not all your tests - you need other levels of test still.  TDD does not validate your system; it only speeds development and improves quality. TDD without a pair programming partner is like programming while wearing only one shoe. ...