Wednesday, September 28, 2011

detecting code smells through tests

I'm spending a lot of time adding tests to completed, working code in our codebase. It's surprising how closely "ability to be easily tested" maps to the quality of the code in question. If I find myself thinking any of these things, the code is probably due for a refactor:
  • "The test for this is going to be really long."
  • "This is going to be hard to test."
  • "This test is going to have a million conditionals."
  • "Crap, I'll need to generate new test data for this scenario."

No comments:

Post a Comment