Developing unit tests

Unit testing is most often used during the development phase, and its purpose is to reduce as many bugs as possible early on, thus decreasing the amount of testing and corrections at higher testing levels. Making the software unit-testable also forces you to create better software architectures, which helps in bug hunting and software maintenance.

Testing methods are sometimes classified to behavioral and structural techniques. Behavioral tests ensure that implementation behaves in the manner it should. For example, implementation takes into account the possibility that streamed data from the network might not fit to the destination buffer. Structural techniques on the other hand verify that all the essential control paths are covered by tests.

In practice it is useful to first create behavioral tests and then measure branch coverage. After that, test cases are added based on structural analysis until necessary coverage is reached.

This section describes the following common testing techniques in detail: