Skip to content
Steven Soloff edited this page Feb 15, 2017 · 1 revision

Overview

Unit testing is typically done by software developers to ensure that the code they have written meets software requirements and behaves as the developer intended.

Naming Conventions

The following naming conventions have been established for unit testing.

Test Fixtures

The naming conventions for test fixtures are summarized below.

  1. Test fixtures that specify contractual requirements for classes that implement the contract are abstract and are named AbstractFooTestCase, where Foo is the name of the abstract type that specifies the requirement.
  2. Test fixtures that ensure a concrete type satisfies the requirements of an abstract type are named BarAsFooTest, where Foo is the abstract type and Bar is the concrete type.
  3. Test fixtures that simply test the implementation of a type not related to any abstract type behavior are named BarTest, where Bar is the type.

The following table provides examples of the above conventions.

Type to Test Test Fixture Test Fixture Purpose
interface IFoo abstract class AbstractFooTestCase Test concrete classes that implement IFoo to ensure they satisfy the interface contract.
abstract class AbstractFoo abstract class AbstractAbstractFooTestCase (1) Test concrete classes that extend AbstractFoo to ensure they satisfy the abstract class contract.
abstract class AbstractFoo class AbstractFooTest Test the implementation of AbstractFoo.
class Bar implements IFoo class BarAsFooTest extends AbstractFooTestCase Test Bar to ensure it satisfies the contract of IFoo.
class Bar extends AbstractFoo class BarAsAbstractFooTest extends AbstractAbstractFooTestCase Test Bar to ensure it satisfies the contract of AbstractFoo.
class Bar class BarTest Test the implementation of Bar not related to any interface it may implement or abstract class it may extend.

(1) Yes, this is ugly, but unfortunately necessary to avoid collisions in test fixture names between interfaces and abstract classes.

Clone this wiki locally