« 10. Design Principle #2 - Independent Test | Main | 8. General Design Principles »

December 02, 2004

9. Design Principle #1 - Dumb Test

Definition

Minimize a test's knowledge about navigation, checking logic and user interface details.

Discussion

This principle is commonly used in application programming where decoupling objects from each other allows each object to change without affecting the other. Applying this principle to test development, the Dumb Test pattern focuses on making an individual test know as little about its surroundings as possible. This makes Dumb Tests less vulnerable to changes in the application, which in turn lead to lower test maintenance costs. Each Dumb Test doesn't know the sequence of steps that were taken to get to the component being tested nor about common checking that has been done by other test modules. Ideally, the only things a Dumb Test is aware of are its inputs and its expected outputs.

Dumb tests work well with the Template, Object Genie, DTO, and Transporter patterns since common test steps can be consolidated into these classes. When the application changes, the bulk of the updates will need to be made in those classes, while individual Dumb Tests will be mostly insulated from the changes. This creates very compact tests that are quick to create and cost less to maintain than tests that provide all the details about navigation and assertions. In a nutshell, a Dumb Test doesn't see the big picture.

Example

Both test cases in the Template pattern example are Dumb Tests (see Figure 3). They have no knowledge of how to login, logout, go to the specials page or search for items. If these parts of the application were to ever change, the Dumb Tests would be unaffected by it. The tests only know that they need to add and remove items from the cart.

Posted by Misha Rybalov at December 2, 2004 11:18 PM

Comments

Post a comment




Remember Me?