How to Start Unit Testing

Sometimes it’s a short post that has lots of great info.

Tim Ottinger wrote about Unit Test Ice Breakers – you have legacy code and you have the motivation to write unit tests. You just don’t know where to start. Here’s what Tim suggests:

  • Start by testing you can instantiating the class.
  • Test that you can call the function at all.
  • Pick the easiest bit of functionality.
  • Write an empty function name and assertion first.
  • Write the function call as you would like it to appear.
  • Refactor the existing tests.
  • Pick the most interesting bit of functionality.
  • Switch partners.
  • Read the code for obvious flaws.
  • Rerun the AT