Test oracles are the mechanisms that determine whether a test result is correct or not. Drawing on the concept coined by William Howden in 1978, the post explains how oracles work across three testing levels. In unit tests, oracles cover return values, local state changes, and interactions with collaborators via mock objects. In integration tests, oracles validate combined outcomes and infrastructure side effects like database writes, file changes, and message queue events. In end-to-end tests, oracles confirm user-visible outcomes, business state propagation across bounded contexts, and external side effects like emails or webhooks. Each level answers a different correctness question, and a comprehensive test suite uses all three oracle strategies together.

7m read timeFrom phpunit.expert
Post cover image
Table of contents
Snakes and CookiesTest OraclesUnit TestsIntegration TestsEnd-to-End TestsConclusion

Sort: