A unit test is a piece of code (usually a method) that invokes another piece of code and checks the correctness of some assumptions afterward. If the assumptions turn out to be wrong, the unit test has failed. A "unit" is a method of a function.
Unit Test RequirementsEdit
- It is automated and repeatable.
- It is easy to implement.
- Once it's written, it stays on for the future.
- Anyone can run it.
- It runs at the push of a button.
- It runs quickly.
Compared to Integration TestsEdit
Methods that perform external communicationEdit
Why have both Unit Tests and Functional TestsEdit
- A unit test will run faster
- A unit test will test the class/component more rigorously and with more test inputs that can be typically tested with a functional test.
- When a unit test fails, it's very obvious where the code is that's broken and needs to be fixed, as opposed to with functional tests where debugging can be time consuming to isolate the problem.
- See Unit Testing.
Community content is available under CC-BY-SA unless otherwise noted.