Skip to main content

What is a Unit Test?

A unit test is a test of the correctness of an individual code module, for example, a test of a method or class. Typically, developers create unit tests for their code as they develop it. A typical unit test is a method that executes the method that it tests and verifies that the method generates the correct output for a given set of inputs.

Unit tests differ from integration tests. Integration tests verify the correctness of the interaction of a set of code modules. Unit tests verify only the correctness of a code module in isolation. Integration tests of a set of code modules could fail even though each module passes its unit tests.

FeedbackOpens in a new tab