Thursday, December 20, 2007

TDD Standards, Naming Conventions

Standard naming conventions applied for code should also be applied for the test codes. But there might be some extra naming conventions in place like starting test methods with Test or having a specific keyword in the test class library name itself.

This page covers basic guidelines about the naming standards.

  • Test name should express a specific requirement

  • Test name should include the expected input or state and the expected result for that input or state

  • Test name should be presented as a statement or fact of life that expresses workflows and outputs

  • Test Name should only begin with Test if it is required by the testing framework or if it eases development and maintenance of the unit tests in some way.

  • Test name should include name of tested method or class

Fxcop is being used in VS2003 as a code analysis tool and in VS2005 it is already integrated to the development environment. You can enable code analysis and select specific rules. It can also be done in nightly builds to make sure your builds do not break your conventions. What if you need a new one? For example how do you make sure all the test methods start with "Test" if you have such a rule? I will explain how to create a custom rule in a different blog entry.

No comments: