2012-03-29

Rules for test driven bug fixing

Just a quick note to myself for how to do bug fixing:

  1. Write an integration test that reproduces the bug
    This should create a test failure which will guard against regressions later on
  2. Write integration tests for the other cases
    You should write at least one test. This should prove that it works the other way so you'll feel safe you don't break behavior later on
  3. Track down the problem to unit level
    Debug to the lowest level where you can find the real cause of the problem
  4. Write a unit test that reproduces the bug
    This should create a test failure which will guard against regressions later on
  5. Write unit tests for the other cases
    You should write at least one test. There may be a chance that other corner cases have slipped as well, so examine closely. Keep in mind that unit tests are cheap!
  6. Now, fix the bug
    Change it so all unit tests are green
  7. Clean up
    Tidy up, don't leave a mess.
    Remember: Someone certainly will have to come back here. If that one is you, you will spend much more time, cursing the one who left that mess than if you do it right now!
  8. Run the unit tests again
    Verify your clean up didn't break anything
  9. Run the integration tests
    These should be green by now
  10. Integrate changes
  11. Create release

1 comment:

  1. Nice algorithm :). However, I would be very careful with the second step ("Write integration tests for the other cases"). This can lead to unmaintainable tests with false assumptions. I would do it only if I thoroughly knew the workflow of the application.

    ReplyDelete

Followers