Categories
Automated Testing

“Never Trust an Automated Test You Haven’t Seen Fail”

My number one philosophy when developing automated tests is:

“Never Trust an Automated Test You Haven’t Seen Fail”

I’ve found it can be easy to write a test that always passes, so forcing a test to fail as a starting point gives me confidence that it can fail.

I know of two ways to make a test fail:

  1. Change the implementation to fail and make sure the test fails at first – fixing the implementation fixes the test
  2. Change the assertion to make a test fail, make sure the actual result is correct and then update the assertion to make the test pass

I don’t really care what method I use to know a test fails, but I make sure I always make it fail. Never trust a test that hasn’t failed.

One reply on ““Never Trust an Automated Test You Haven’t Seen Fail””

Do you know who said it first? (“Never Trust an Automated Test You Haven’t Seen Fail”.) It’s been my motto for years too, but I can’t remember where I’ve seen it first.

Leave a Reply

Your email address will not be published. Required fields are marked *