XP Home

Unit Tests

Lessons Learned

Continued from page 1

 Unit tests enable refactoring as well. After each small change the unit tests can verify that a change in structure did not introduce a change in functionality.
 Building a single universal unit test suite for validation and regression testing enables frequent integration. It is possible to integrate any recent changes quickly then run your own latest version of the test suite. When a test fails your latest versions are incompatible with the team's latest versions. Fixing small problems every few hours takes less time than fixing huge problems just before the deadline. With automated unit tests it is possible to merge a set of changes with the latest released version and release in a short time.
 Often adding new functionality will require changing the unit tests to reflect the functionality. While it is possible to introduce a bug in both the code and test it rarely happens in actual practice. It does occasionally happen that the test is wrong, but the code is right. This is revealed when the


problem is investigated and is fixed. Creating tests independent of code, hopefully before code, sets up checks and balances and greatly improves the chances of getting it right the first time.
 Unit Tests provide a safety net of regression tests and validation tests so that you can refactor and integrate effectively. As they say at the circus; never work without a net! Creating the unit test before the code helps even further by solidifying the requirements, improving developer focus, and avoid creeping elegance. unit test framework

Unit TestsUnit tests

ExtremeProgramming.org home | XP Rules | Download a Unit Test Framework | Email the webmaster

Copyright 1999 J. Donovan Wells all rights reserved.