Unit Test and TDD Fundamentals
TDD results in unit tests. A unit test verifies the behavior of a code unit, where a unit is the smallest testable piece of an application. You typically write a unit test in the programming language of the unit.
Unit Test Organization and Execution
A single unit test consists of a descriptive name and a series of code statements, conceptually divided into four (ordered) parts.
(Optional) statements that set up a context for execution
One or more statements to invoke the behavior you want to verify
One or more statements to verify the expected outcome
(Optional) cleanup statements (for example, to release allocated memory)
Some folks refer to the first three parts as Given-When-Then. In other words, Given a context, ...