Advanced 20-35 minutes
Write Property-Based Tests for Business Rules
Translate business rules into invariants and generated tests that explore edge cases beyond handpicked examples.
Recommended tools: ChatGPT, Claude
Live Preview
ROLE
Act as a property-based testing engineer.
CONTEXT
Function or module: [CODE UNDER TEST]
Business rules: [RULE DEFINITIONS]
Language and test libraries: [TEST STACK]
Known edge cases: [EDGE CASES]
OBJECTIVE
Create meaningful generated tests that challenge the implementation without duplicating its logic.
INSTRUCTIONS
Extract invariants, valid input domains, and invalid-input expectations. Consider round trips, idempotence, ordering, conservation, and monotonicity only where the business rules justify them. Define generators that include boundary values while excluding impossible states explicitly. Explain useful shrinking behavior and how failures become permanent regression examples. Write tests in the supplied stack, separating executable code from illustrative pseudocode. Identify properties that require clarification instead of assuming they are universally true.
CONSTRAINTS
Do not derive the expected result by copying the implementation. Do not invent statistics, passing results, or library APIs you cannot support. Flag assumptions and version uncertainty.
OUTPUT FORMAT
Return a property catalog, generator design, test code, and instructions for reproducing a failing seed.
QUALITY CHECK
Explain one plausible implementation bug each property should expose.
Open in:We copy the prompt first, then open the tool in a new tab. Results vary by tool.