# Test - Unit Test

Generally, in xUnit framework, a test is procedure that must not throw an exception.

A test is just a sort of IF statement written in a method. A lot of framework use a collection of assertion method. Not to confound with assertion that are written in the code, this assertions are written in the test method only and are part of a test framework..

Example:

assertEquals(object1, object2)

Tests Make Software.

If you haven't seen a test fail, you don't know if the test works.

Whenever you are tempted to type something into a print statement or a debugger expression, write it as a test instead. Martin Fowler

Unit Tests are primarily written as a good practice to help developers identify and fix bugs, to refactor code and to serve as documentation for a unit of software under test. To achieve these benefits, unit tests ideally should cover all the possible paths in a program. One unit test usually covers one specific path in one function or method. However a test method is not necessary an encapsulated, independent entity. Often there are implicit dependencies between test methods, hidden in the implementation scenario of a test. Adrian Kuhn et. al.

## 3 - When

Whenever you are tempted to type something into a print statement or a debugger expression, write it as a test instead. Martin Fowler