This blog has moved to Medium

Subscribe via email


Don’t fix your tests too quickly

You know the classic workflow to fixing bugs?

  1. Find bug
  2. Write test
  3. Make sure test fails
  4. Fix bug
  5. Makes sure test passes
  6. Profit!

Sometimes, after you fix the bug, the test still fails. This means the test was flawed!

In this case, besides fixing the flawed test, you should go back to step 1 – undo the bugfix, write a better test or fix the test, make sure it fails with the original code, and only then fix it (the “lazy flow” is just to fix the test and watch it turn green, but then you don’t really know it tested what you wanted).