Monday, July 02, 2012

Tip of the Day: Unit Testing Code Review


Here are some general best practices to consider around unit test code review.

These tips are by no means definitive, but serve as reminders to developers what they should consider in a checklist.

Note: unit testing and code reviews are really not separate processes.
  • Unit tests are added for each code path, and behavior. This can be facilitated by tools like Sonar, and Cobertura.
  • Unit tests must cover error conditions and invalid parameter cases.
  • Unit tests for standard algorithms should be examined against the standard for expected results.
  • Check for possible null pointers are always checked before use.
  • Array indices are always checked to avoid ArrayIndexOfBounds exceptions.
  • Do not write a new algorithm for code that is already implemented in an existing public framework API, and tested.
  • Ensure that the code fixes the issue, or implements the requirement, and that the unit test confirms it. If the unit test confirms a fix for issue, add the issue number to the documentation.


Popular Posts