Overview |  | Roles |  | Work Items |  | Views |  | CMMI |  | Index |  | Glossary |

Project Portal
| ### Next Steps Perform Unit Test for Bug Fix |
| Write or Update a Unit Test for Bug Fix ( 3 : VER : 1 : 1.3 ) Developer
Activity: Write or Update a Unit Test for Bug Fix
Developer
|  |  |  | Build |  |  |  | Stabilize |  |
|  | Participating Roles Responsible: Developer
### Overview Unit tests verify the proper implementation of a unit of code. Writing and performing unit tests identifies bugs before testing begins and therefore helps reduce the cost of quality control. Developers must write unit tests for all code that will be written as part of implementing a development task, or implementing a bug fix. # Entry Criteria The bug work item is in the Active state. The bug work item is in the Active state. The task work item is in the Active state. The task work item is in the Active state. # Sub-Activities
1 | Identify the Unit Test Scope | Identify the types of unit tests to be written. Positive unit tests exercise the code as intended and check for the right result. Negative unit tests intentionally misuse the code and check for robustness and appropriate error handling. Fault injection unit tests expose error-handling anomalies.
2 | Write or Update the Unit Test | Write unit tests for the development task covering as much of the functionality as possible. Use scaffolding and mock objects to maximize the code surface area tested. If the code has already been written, generate unit tests from the working code.
3 | Validate the Unit Test | Perform a run on the test, making sure the test fails for any element not completed and passes if the element is working as expected. Correct the portions of the unit test that yield incorrect or ambiguous results.
# Exit Criteria
| The unit test is written and validated.
© 2005 Microsoft Corporation. All rights reserved. MSF for CMMI Process Improvement: 1.00.0000.00 |