Qualified
Unit testing concept
- unit is the smallest testable part of an application (function, class, module, component)
- each test case is independent from the others (mocks, stubs)
- tests that impact the behavior of the system.
Advantages
- The goal of unit testing is to isolate each part of the program and show that the individual parts are correct
- finds problems early in the development cycle
- allows to refactor code or upgrade system libraries at a later date, and make sure the module still works correctly
- provides a sort of living documentation of the system.
- cost of fixing a defect detected during unit testing is lesser
- debbuging is easy
Disadvantages
- difficulty of setting up realistic and useful tests.
- 2 tests for each if(){}
- not easy for not pure function
F.I.R.S.T. principles of Unit tests
Fast - many 100 or 1000 per secondsIsolates - failure reasons become obviusRepeatable - run repeatedly in any order, any time, any envSelf-validating - no manual evaluation required, only pass/fail statusTimely - written before the code