Definition: A mnemonic for choosing which test cases to write and in what order, with each letter standing for a type of case: Zero, One, Many (or more complex), Boundary behaviours, Interface definition, Exercise exceptional behaviour, and Simple scenarios with simple solutions. Tests are added one behaviour at a time, starting from the simplest case.
So what? It gives developers, particularly those practising TDD, a structured way to decide where to start and what to test next, so test cases are built up gradually rather than chosen chaotically.
Example: Testing a shopping cart class: a Zero case checking an empty cart has a total of nil, a One case adding a single item and asserting the total matches its price, a Many case adding several items and asserting the summed total, a Boundary case at the maximum allowed quantity, an Interface case raising an exception when a non-product is added, an Exceptional case rejecting a duplicate item, and a Simple scenario confirming one item still prices correctly.
So what? It gives developers, particularly those practising TDD, a structured way to decide where to start and what to test next, so test cases are built up gradually rather than chosen chaotically.
Example: Testing a shopping cart class: a Zero case checking an empty cart has a total of nil, a One case adding a single item and asserting the total matches its price, a Many case adding several items and asserting the summed total, a Boundary case at the maximum allowed quantity, an Interface case raising an exception when a non-product is added, an Exceptional case rejecting a duplicate item, and a Simple scenario confirming one item still prices correctly.