A schema-based unit test generates arguments that conform to an input schema, calls the function, and checks whether the result conforms to an output schema. It replaces hand-picked examples with varied generated data while keeping the contract explicit. section 12.5
A practical test flow is:
- Generate data with JSON Schema Faker, from a UUID to a nested catalog. section 12.5
- Call the function with generated arguments and validate its return value against the response schema. section 12.5
Searching generated catalogs
A refined test selects the first generated book, searches for its first title character, and returns false on an exception. The failure identifies invalid authorNames values; correcting the fallback makes the test pass.
Follow the diagram to see generated arguments, function execution, and return-schema validation as one testing loop. section 12.5
