Guideline: Writing Unit Tests |
Write unit (black box) tests that validate subsystems and components before they're integrated with the rest of the implementation.
Relationships
Related Elements | Developer Implement Unit Tests
Main Description
Unit testing is implemented against the smallest testable element (units) of the software, and involves testing the unit's function and observable behaviors. The design and implementation of tests to verify the unit's observable behaviors and functions do not rely upon a knowledge of the implementation and therefore is known as black-box approach. Deriving unit tests based upon the black-box approach utilizes the input and output arguments of the unit's operations, and/or output state for evaluation. For example, the operation may include an algorithm (requiring two values as input and return a third as output), or initiate change in an object's or component's state, such as adding or deleting a database record. Both must be tested completely. To test an operation, you should derive sufficient test cases to verify the following: an appropriate value was returned by the operation for each valid value used as input an appropriate value was returned by the operation for each invalid value used as input an appropriate output state occurs for each valid input state an appropriate output state occurs for each invalid input state
More Information
Concepts | Developer Testing
Guidelines | Developer Testing
© Copyright IBM Corp. 1987, 2009. All Rights Reserved.