Epic Fail!

At this point, you are probably thinking that a good test is a passing test. Test failures are bad, right? They mean something is broken, and broken is bad. I would argue that you always want your tests to fail before they pass. When I first started writing unit tests, I was really enjoying myself. I loved all those green checkmarks indicating that all my tests were passing. I was pretty proud of myself. I started sharing my code and test code with the other programmers I worked with. Soon, though, I discovered through manual testing that my application code had a really serious bug. My unit tests were supposed to be testing for that bug, but for some reason, the tests were still passing. It turns out that I had written my tests so ...

Get Learning to Program 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.