edge case
An input at the limits of what code must handle, such as an empty list, zero, a single item or the largest allowed value.
In more detail
Bugs cluster at edges, so tests should include them alongside ordinary cases. Off-by-one errors are the classic edge-case failure.
Examples
Go: add a table row for empty input before adding the branch that handles itIn this course: For numbers that means zero, one, negative values, the boundary and one past it; for text, the empty string, one character, spaces and accented letters. A name like test_discount_edge is not enough: say which edge and what should happen there.Related terms
- table-driven test — A Go test style that lists many input cases and expected results as rows in a slice, then checks them all in one loop.
- unit test — An automated check of one small piece of code, such as a single function, that runs quickly and on its own.
- off-by-one error — A bug where a count or index is one too many or one too few, such as looping one step past the end.
- parametrized test — One test function run many times with different data, each run reported as a separate test case.
- rounding — Turning a number with a fractional part into a whole number by a chosen rule, such as nearest, towards zero or half to even.
- happy path — The route through code when everything goes as intended, with valid input and no errors.
Taught in
- Writing Table Driven Tests — Concurrent Systems Programming with Go
- Testing With pytest — Hands-on Python: Complete Video Course & Book
- Parametrised Tests — Automated Testing, TDD & Quality Engineering
- Naming Tests For Readability — Automated Testing, TDD & Quality Engineering
- Testing Time And Randomness — Automated Testing, TDD & Quality Engineering