Codebase Guidelines

The TFS Deployer codebase has passed through the hands of several developers over the years and as a result there is some inconsistency in the style and technique of the existing code. However all future contributions should adhere to the following guidelines.

All Code

  • Regions (ie #region) should never be used.
  • Private instance field names should begin with an underscore.

Production Code

  • TFS Deployer does not use an IoC container (yet) but classes should use constructor-injection for obtaining dependencies.
  • The app.config should only be used to store the minimum settings for TFS Deployer to connect to an instance of TFS and retrieve the DeploymentMappings.xml file where all other settings exist.
  • Changes to settings stored in DeploymentMappings.xml files should be reflected in the DeploymentMappings.xsd file, the DeploymentMappings.cs file, and in the Samples\DeploymentMappings.xml file.
  • Existing users of TFS Deployer should be able to upgrade to newer versions with the least disruption to their existing configuration. Choose sensible defaults and avoid breaking changes.

Tests

  • All new features and bug fixes should start by introducing a failing automated test to describe the required change.
  • Tests are implemented using the MSTest framework.
  • Tests should not be dependent on running with certain (eg Administrator) permissions unless the test is specifically verifying permissions-related behaviour.
  • There should be at least one test class per class under test.
  • Test classes should be named based on the class under test plus a "Tests" suffix. eg: The test class for TfsDeployer.Alert.EmailAlerter would be Tests.TfsDeployer.Alert.EmailAlerterTests.
  • There should only be one Assert per test method except where multiple Asserts are required to verify a single concept.
  • Test method names should be prefixed with the name of the class under test followed by an underscore-separated sentence describing what the test is verifying. eg: EmailAlerter_should_send_email_containing_script_results.
  • Test method code should be grouped into the following commented sections: Arrange, Act, Absterge (optional), and Assert.
  • Test classes should not use methods marked with TestInitialize or TestCleanup attributes. Discussed here

Last edited Oct 28, 2010 at 3:46 AM by jstangroome, version 7

Comments

No comments yet.