2.3. It’s not good if it’s testing the wrong things
More than once I’ve concluded a journey of reading and debugging code to find the cause for an undesirable system behavior at almost the same place I started looking. A particularly annoying detail overlooked in such a bug-hunt is the contents of a test. The first thing I tend to do when digging into code is to run all the tests to tell me what’s working and what’s not. Sometimes I make the mistake of trusting what the tests’ names tell me they’re testing. Sometimes it turns out that those tests are testing something completely different.
This is related to having a good structure—if a test’s name misrepresents what it tests, it’s akin to driving with all the road signs turned the wrong way. ...
Get Effective Unit Testing now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.