liveBook · Manning

Edge case

As explained in Unit Testing Principles, Practices, and Patterns

A boundary or unusual condition in a business scenario that may require distinct behavioral verification.

An edge case occurs when executing a business scenario results in an error. Unit tests should cover as many such cases as possible because they are fast and maintainable. section 8.1

Allocate edge-case coverage according to cost and system boundaries:

  • Use unit tests for most business-scenario errors, where fast feedback and low maintenance matter. section 8.1
  • Use integration tests for errors that unit tests cannot cover, alongside one successful execution per business scenario. section 8.8
  • Keep the ratio responsive to project complexity; simple applications may need equal unit and integration coverage. section 8.8
Figure 8.2. The Test Pyramid represents a trade-off that works best for most applications. Fast, cheap unit tests cover the majority of edge cases, while a smaller number of slow, more expensive integration tests ensure the correctness of the system as a whole.

The Test Pyramid visualizes the trade-off: fast, cheap unit tests handle most edge cases, while fewer integration tests verify the system as a whole. section 8.1

How Unit Testing Principles, Practices, and Patterns covers it

How deep it goes
Defines errors as edge cases and explains their placement in a Test Pyramid, without detailing individual test implementations.
Examples
Uses business scenarios, successful paths, and project-complexity variations as test-allocation examples.
What it assumes
Assumes distinctions between unit tests, integration tests, and successful business-scenario execution.
What you can do after
Apply the Test Pyramid by placing most business-scenario errors in unit tests and exceptional cases in integration tests.
How it connects
Connects edge cases with unit testing, integration testing, happy paths, and the Test Pyramid.

Also explained in

Compare how 7 books explain edge case →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Unit Testing Principles, Practices, and Patterns. The section links point to the parts of the book it draws on.