Unit testing is the cornerstone of Extreme Programming (XP), which relies on
an automated unit testing framework. This automated unit testing framework can
be either third party, e.g. xUnit, or created within the development group.
Extreme Programming uses the creation of unit tests for test-driven
development. The developer writes a unit test that exposes either a software
requirement or a defect. This test will fail because either the requirement
isn't implemented yet, or because it intentionally exposes a defect in the
existing code. Then, the developer writes the simplest code to make the test,
along with other tests, pass.
All classes in the system are unit tested. Developers release unit testing
code to the code repository in conjunction with the code it tests. XP's thorough
unit testing allows the benefits mentioned above, such as simpler and more
confident code development and refactoring, simplified code integration,
accurate documentation, and more modular designs. These unit tests are also
constantly run as a form of regression test.