mercoledì 3 novembre 2010

Naming domain model's unit tests

After some thought about a consistent naming convention for unit tests related to domain models, I reached a conclusion.

First of all I have to refactor my tests to get a single logical assertion per test.

I will prefix test fixtures with QA (for quality assurance): while "Test" and "Unit" are terms that appeares in many ubiquitous language (eg StressTest or MeasurementUnit).

I will keep the current namespace organization, that diverge from the organization of the classes under test, since it make it easer to check coverage with mono.

The method name will follow the following convention:
  • each unit test name will start with the verb/method/message under test, followed by an underscore
  • a description of the scenario/preconditions (tipically a semantical description of the arguments), followed by an underscore
  • a description of the assertion

The form will be Verb_Scenario_Assertion.

Here some examples:
I'll add some words to the names (like "with", "fire" or "return") to clarify the test's semantic.

I'd really like to take some comment about this convention (since I've to refactor more than 400 tests right now, and I'd like to do such work only once).

1 commento:

  1. Have you looked at the Given/When/Then convention?