Reworking Single Tests

Looking at a single test case, a testXXX method, we can see that several points deserve our attention:

The following rule applies in general: the bigger the distance between input and output data, the more difficult it will be to understand the test. For example, if we decide to relocate test data into a file, then the expected results should also be in this file. The next best solution would be to have a file with a similar name (e.g., testData.input and testData.expected) near the test itself.

Each team will develop their own basic vocabulary with test idioms and guidelines during the course of a project. Things that win through standardization include the use of the optional string parameter in assert calls or the naming of test fixture variables. One of the important aspects of guidelines is their consistent use. Far less important are the concrete contents of individual rules. [2]Binder [99, p. 917] dedicates an entire chapter to oracles. [3]An excellent example of how greatly opinions can vary is demonstrated in Gassmann [00], where the opposite rule is stated.