Test driven development is a software development paradigm in which test are written before code. Testing should be done early and often. Testing is a continuous process that should be performed at each stage of software development. # unit test A unit test covers the low level aspects of a system. For each method `foo()` there should be another method `testFoo()`. # integration test Integration tests check that the modules work together in combination. # acceptance test Acceptance tests are tests performed by the user (or product owner) to check that the delivered system meets their needs. Often these are written first to inform integration tests and unit tests. This is called **outside-in testing**. # code coverage Full code coverage is when tests cover all possible states of the code. Components of coverage include - **statement coverage**: all statements have been executed by a test - **branch (edge) coverage**: each edge in a program's control flow graph have been executed - **condition coverage**: like branch coverage but with emphasis on all combinations of conditions (if/then branches and guard clauses in code) - **path coverage**: all paths in a program's control flow graph have been executed multiple times. # test double A test double is an object that "doubles" an object in code for the purpose of testing. - **stub**: replaces the real component with a canned answer - **spy**: mock or stub that records, implements the 2 or 3 methods of interest - **mock**: replaces real component with pre-programmed expectations - **fake**: replaces real component with shortcuts - **dummy**: placeholder object, never actually used # dependency injection > [!Tip]- Additional Resources > - [Test Driven Development by Kent Beck](https://www.amazon.com/Test-Driven-Development-Addison-Wesley-Signature-ebook/dp/B0CW1JBTHM/)