Task: Implement Developer Tests |
Implement one or more tests that enable the validation of the individual software components through execution.
Disciplines: Implementation
Purpose
Validate a software component (e.g. an operation, a class, a stored procedure) through unit testing. The result is one or more new tests, including set up code/data and expected results, which are added to the unit test suite.
Relationships
Roles | Primary Performer: Developer | Additional Performers:
Inputs | Mandatory: Implementation | Optional: Design Test Script
Outputs | Developer Test
Main Description
Developer testing is different from other forms of testing in that it is based on the expected behavior of code units rather than being directly based on the system requirements.
Steps
Refine scope and identify the test(s)
Select the increment of work to be tested and identify test(s) to verify that the code being developed for it behaves correctly. It is best to do this at a small scale, much smaller than the complete code base to be authored by a developer over the course of an iteration. This can be done for one operation, one field added to a user interface, one stored procedure, etc.
Write the test setup
Describe the setup that must be done before running each test. To successfully run a test, the system must be in a known state.
Write the test logic
Write the steps that performs the test(s). For the sake of repeatability and support for regression testing, it is highly desirable that the test steps be automated code.
Define the expected results
Define the expected results of each test so that it can be verified. After a test runs, you need to be able to compare the results of running the test against what was expected to happen. The test is successful when the actual results match the expected results. As with other facets of developer tests, this verification of results is best automated.
Define the test response
Define the information the test(s) must produce to successfully indicate failure. Consider if a response of True or False sufficient, or if a detailed message should be logged as well.
Write clean-up code
Identify, and then implement, the steps to be followed in order to restore the environment to the original state. The goal is to ensure that there are no side effects from running the test(s).
Test the test
Verify that each test works correctly. Check the setup. Run the test, observe its behavior, and fix any defects. In particular, ensure that the expected results are defined properly and that they're being checked correctly. Check the clean-up. If a test framework is being used to manage a suite of unit tests, ensure the unit test works within the framework.
Key Considerations
Automate tests via a unit regression testing tool (e.g. xUnit) so that tests may be run by developers whenever they make changes to the code. Test to the risk of the component. For example, the more critical a component is, the more important it is that it be tested thoroughly. The developer needs testing skills to be able to perform this task properly. They may need to pair program with someone with those skills, such as another developer or a tester.
Alternatives
Rely on an external testing organization to validate your software. This will likely prove to be very time consuming, expensive, and not as effective as developer testing.
More Information
Concepts | Test-first Design
Guidelines | Developer Testing
This program and the accompanying materials are made available under the Eclipse Public License v1.0 which accompanies this distribution. View copyright information here: OpenUP Copyright