There’s a conventional wisdom that says software developers can’t test their own code. I think it’s really more intended to say that you can’t meaningfully test the behavior of software that you’ve written to behave a certain way. The reasoning is simple enough. If you write code with the happy path in mind, you’ll always navigate the happy path when testing it, being hoodwinked by a form of confirmation bias.
To put it more concretely, imagine that you write a piece of code that reads a spreadsheet, tabulates sums and averages, and reports these to a user. As you build out this little application, one of the first things you’ll do is get it successfully reading the file so that you can write the other parts of the application that depend on this prerequisite. Over the course of your development, you’ll be less likely to test all of the things that can go wrong with reading the spreadsheet because you’ll develop kind of a muscle memory of getting the import right as you move on to test the averages and sums on which you’re concentrating. You won’t think, “what if the columns are switched around” or “what if I pass in a Word document instead of a spreadsheet?”
Because of this effect, we’re scolded not to test our own software. That’s why QA departments exist. They have the proper perspective and separation so as not to be blinded by their knowledge of how things are supposed to go. But does this really mean that you can’t test your own software? It may be that others are more naturally suited to do it, but you can certainly work to reduce the size and scope of your own blind spot so that you can be more effective in situations where circumstances press you into testing your own code. You might be doing a passion project on the side or be the only technical member of a startup – you won’t always have a choice.
Let’s take a look at some techniques that will help you be more effective at testing software, whether written by you or someone else. I originally wrote this post for the Infragistics blog, so click here to read about the techniques to which I’m referring.