In programming, an edge case typically involves input values that require special handling in an algorithm behind a computer program. As a measure for validating the behavior of computer programs in such cases, unit tests are usually created; they are testing boundary conditions of an algorithm, function or method. A series of edge cases around each "boundary" can be used to give reasonable coverage and confidence using the assumption that if it behaves correctly at the edges, it should behave everywhere else.2
For example, a function that divides two numbers might be tested using both very large and very small numbers. This assumes that if it works for both ends of the magnitude spectrum, it should work correctly in between.3
Programmers may also create integration tests to address edge cases not covered by unit tests.4 These tests cover cases which only appear when a system is tested as a whole. For example, while a unit test may ensure that a function correctly calculates a result, an integration test ensures that this function works properly when integrated with a database or an external API. These tests are particularly relevant with increasing system complexity in distributed systems, microservices, and Internet of things (IoT) devices. With microservices in particular, testing becomes a challenge as integration tests may not cover all microservice endpoints, resulting in uncovered edge cases.5
Other types of testing which relate to edge cases may include load testing and negative/failure testing. Both methods aim at expanding the test coverage of a system, reducing the likelihood of unexpected edge cases.
In test-driven development, edge cases may be determined by system requirements and accounted for by tests, before writing code. Such documentation may go inside a product requirements document after discussions with stakeholders and other teams.
Beram, Shehab (2023-08-03). "What is an edge case? Meaning, examples in software development". LogRocket Blog. Retrieved 2023-10-24. https://blog.logrocket.com/product-management/edge-case-software-development/ ↩
Zimmerman, Josh (2012). "Unit Testing" (PDF). Principles of Imperative Computation. cs.cmu.edu. Retrieved 2014-01-16. https://www.cs.cmu.edu/~rjsimmon/15122-s13/rec/07.pdf ↩
Cho, Shinil (October 2018), "The Fourier transform", Fourier Transform and Its Applications Using Microsoft EXCEL®, IOP Publishing, doi:10.1088/978-1-64327-286-3ch2, ISBN 978-1-64327-286-3, S2CID 210754571, retrieved 2022-02-17 978-1-64327-286-3 ↩
Khorikov, Vladimir (2019). Unit Testing: Principles, Practices, and Patterns. Manning Publications. pp. 188–190. ISBN 978-1617296277. 978-1617296277 ↩
Hossain, Md. Delowar; Sultana, Tangina; Akhter, Sharmen; Hossain, Md Imtiaz; Thu, Ngo Thien; Huynh, Luan N. T.; Lee, Ga-Won; Huh, Eui-Nam (2023-06-23). "The role of microservice approach in edge computing: Opportunities, challenges, and research directions". ICT Express. 9 (6): 1162–1182. doi:10.1016/j.icte.2023.06.006. ISSN 2405-9595. https://doi.org/10.1016%2Fj.icte.2023.06.006 ↩