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

Project Portal
| ### Next Steps Write Code for a Development Task Perform a Unit Test |
| Activity: Create or Update a Unit Test
Developer
|  |  |  | Fix a Bug |  |
|  | Participating Roles Responsible: Developer
### Overview Unit tests verify the proper implementation of a unit of code. Performing unit tests during development reduces the number of bugs discovered during testing and helps avoid regression bugs when fixing other bugs or adding new features. Unit tests are not functional tests or integration tests and they only test the operation of the code in isolation. Developers must make sure existing unit tests still pass after writing new code. Running test cases occurs throughout the software development process, starting with the earliest functionality and architectural elements and finishing with regressions at the end of the project. There are different types of test cases, such as verifying scenarios and quality of service requirements. Each of these test types have the same process for running and potentially identifying bugs. # Entry Criteria Dependencies: The bug or development task associated with the unit test is clearly defined. # 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 | Run the test, making sure the test fails for any element not completed and passes if the element is working as expected. Correct portions of the unit test that yield incorrect or ambiguous results.
# Exit Criteria
| The unit test is written and fails if the code is not written for the test.
(C) 2005 Microsoft Corporation. All rights reserved. Build 97 |