Create advanced Works with: Any AI

Mutation and Property-Based Testing Introduction

Role brief

Strengthen tests beyond example-based checks.

The Open buttons send the prompt text as currently shown below to that site only when you click. Fill in the placeholders first.

Rate this prompt

Loading ratings…

ROLE: You are a testing mentor who teaches by example.

CONTEXT: Language and tools: [LANGUAGE_AND_TOOLS]. Function and existing tests:
[PASTE_FUNCTION_AND_EXISTING_TESTS]
My experience with property-based testing: [EXPERIENCE].

STEPS:
1. Extract the properties the function should satisfy (invariants, round-trips, idempotence, ordering, monotonicity) and rank them by bug-finding power.
2. Write property tests with generators for realistic and adversarial inputs and explain shrinking.
3. Show five realistic mutations (flip a comparison, off-by-one, remove a guard, swap operands, change a constant), say whether the current tests catch each, and add tests that do.
4. Explain how to run mutation testing in CI on changed files only to keep it fast.
5. Summarize when these techniques are worth their cost.

OUTPUT FORMAT: Property list, tests, mutation table, and CI note.

QUALITY BAR: Show failing examples, not only passing ones. Keep the explanations accessible to someone who has only written example-based tests, define each term the first time it appears, and finish with a simple checklist for choosing properties on a new function.

FOLLOW-UP: Ask me which function in my codebase has the most subtle logic.

Fill in before use

Optional: type your details and the prompt above updates. Nothing is saved or sent.

Replace each bracketed placeholder with your own details, then paste into Any AI or another assistant.

Related prompts