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:
- Change the implementation to fail and make sure the test fails at first – fixing the implementation fixes the test
- 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.