FANDOM


DefinitionEdit

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

Integration tests occurs when two or more dependent software modules as a group are tested together. Unit tests are not integration tests, and integration tests are not unit tests.

Methods that perform external communicationEdit

Any method that performs "external communications" (see Three types of methods) should be stubbed out. See discussion on mocking.

Why have both Unit Tests and Functional TestsEdit

  1. A unit test will run faster
  2. A unit test will test the class/component more rigorously and with more test inputs that can be typically tested with a functional test.
  3. 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.

ReferencesEdit

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.