MSF for Agile Software Development Visual Studio 2005 Team System logo

Activity:

Create or Update a Unit Test

Participating Roles

Responsible:

Developer

Overview

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

    • Identify unit tests for the development task covering as much of the functionality as possible. Perform write unit test, validate that the unit test fails, write or refactor code, and perform unit test until all of the identified tests for the task are completed.
    • Write or update a single unit test at a time.
    • 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.

    © 2006 Microsoft Corporation. All rights reserved.

    Version 4.1.0