Dont Change The Code Test

Does it seem impossible to automatically UnitTest that one bit of code? Or, if it's possible, does it not seem cost-effective? Well, if you run plum out of ideas, there's always the "Don't Change The Code" Test:

  1. Pare down the amount of untestable code as much as possible.
  2. Take that small bit, and manually verify its results.
  3. Create a test assertion that has:
    1. Some mechanism to detect if anyone changes the code (string comparison, datestamp comparison, MD5Sum comparison, etc.)
    2. Any expectations you have for the code inside the "test failed" message.

Situations where this has successfully been used: Situations where this would probably be successful (if you've actually done this, and liked it, please move the items you have experience up to the previous list):


CategoryTesting


EditText of this page (last edited March 11, 2012) or FindPage with title or text search