Once complexity metrics, like Cyclomatic complexity, have flagged a method, three proactive steps can be taken to reduce the risk of defects:

  1. Write tests for that method
  2. Refactor the method into smaller, more isolatable methods
  3. Write tests for those newly created methods

This flash demo walks you through the steps of applying the Extract Method refactoring pattern within Eclipse and writing a corresponding test case utilizing the JUnit-addons framework.

Watch the demo.