Basic Test Sheets

Test Sheets are basically spreadsheets. Example:

(click to enlarge)

A Test Sheet consists of a name and a class being tested. Each row after that represents one method call. The first column identifies the object being tested while the second column indicates which method is being called on said object. In the example each row calls the static method Search of the class SearchUtilities. Input parameters are specified in the columns following the method name up to the invocation line. In the example the parameters are a search string (third column) and a text string in which the search string shall be looked for (fourth column). Right after the invocation line the expected return values can be specified. In this case those are a boolean value which indicates if the search string was found at all and an integer which points to the position of the token which matched the search string.

A Result Sheet is shown as well. It differs from the input in that it has a new name and that it references the original sheet's name. Also the cells with expected values have been colored. Green for cells in which the expected value matched the value returned after executing the test, red otherwise. In case of a value mismatched both the expected value and the actual value are shown in the cell. This Result Sheet points to two issue with the class. It handles an empty search string incorrectly and it starts at 0 when counting positions while starting with 1 is expected.

The next example shows a Test Sheet which uses an actual instance of a class:

(click to enlarge)

This examples works similarly to the previous one except that it uses cell names to reference objects and data. In the third row an object is created. The class used for instantiation is referenced via A2 as the class defined in the first column of the second row. The newly created object is the first value returned and so the first column after invocation line, which is D3, refers to said object. This means that all subsequent rows, which reference D3 in the first column, invoke methods on the newly created object. Rows 4, 6 and 8 randomly generate an integer for testing. The actual value created in each case can be referenced via C4, C6 and C8, i.e. the names of the cells which generate the random numbers. This Test Sheets tests a stack implementation by creating a stack which can hold three items, pushing three random numbers onto the stack and testing whether they can be taken off the stack properly.