liveBook · Manning

Edge case

As explained in Software Engineering for Data Scientists

An edge case is an unusual, boundary, or exceptional input or operating condition that may expose incorrect program logic.

An edge case is an unusual, boundary, or exceptional input or operating condition that may expose incorrect program logic. Testing these cases checks that code handles unexpected values and situations deliberately. section 10.1

Include edge cases when testing:

  • Invalid or implausible values, such as a customer age of 500 or an age represented as a string. section 10.1
  • Unexpected control-flow conditions, including both outcomes of if-else statements and try/except clauses. section 10.1
  • Missing results, such as a database query returning no data, and inputs that could cause model or function failure. section 10.1 section 10.4

Treat edge-case tests as part of broader test coverage. Covering many ordinary paths is not enough if important branches, error-handling paths, or unusual inputs remain unexecuted. section 10.4

A practical test target

For a customer-age feature, test a normal numeric age, a string value, and an implausible value such as 500. Then verify that the intended validation or handling logic runs rather than allowing an unnoticed failure. section 10.1

Listing 10.21 Use the coverage library to generate an HTML report showing what lines were not executed during testing.
coverage html ch10/test_full_pipeline.py #1

Generate an HTML coverage report to find lines that no test executes; use the uncovered lines to identify missing edge-case tests. section 10.4

How Software Engineering for Data Scientists covers it

How deep it goes
Defines edge cases and gives input and control-flow examples, but stops short of prescribing a complete testing procedure.
Examples
Uses an implausible customer age, a string-valued age, an empty database result, and unexecuted conditional lines.
What it assumes
Assumes basic familiarity with inputs, conditionals, exceptions, models, and tests; teaches why unusual cases require explicit checks.
What you can do after
Diagnose/debug missing test paths by testing unusual inputs and inspecting coverage reports for unexecuted lines.
How it connects
Connects edge cases with input validation, unit testing, integration testing, exception handling, and test coverage.

Also explained in

Compare how 13 books explain edge case →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Software Engineering for Data Scientists. The section links point to the parts of the book it draws on.