Harness Property Test
Property-based and generative testing with fast-check, hypothesis, and automatic shrinking. Discovers edge cases that example-based tests miss by generating thousands of random inputs and verifying invariants hold for all of them.
When to Use
- Testing functions with large input spaces (parsers, serializers, encoders, validators)
- Verifying mathematical or algebraic properties (commutativity, associativity, round-trip encoding)
- Finding edge cases in data transformation, sorting, or filtering logic
- NOT when testing UI rendering or visual output (use harness-visual-regression instead)
- NOT when testing simple CRUD operations with well-defined inputs (use harness-tdd instead)
- NOT when testing external service integrations (use harness-integration-test instead)
Process
Phase 1: IDENTIFY -- Discover Testable Properties and Invariants
Catalog candidate functions. Search for functions that exhibit testable properties:
- Pure functions with deterministic output for given input
- Serializers/deserializers where
decode(encode(x)) === x (round-trip property)
- Sorting/filtering where output maintains invariants (sorted order, subset relationship)
- Validators where valid input always passes and specific invalid inputs always fail
- Mathematical functions with known algebraic properties
Identify properties for each candidate. Common property categories:
- Round-trip:
deserialize(serialize(x)) === x for any valid x
- Idempotence:
f(f(x)) === f(x) (applying the function twice gives the same result)
- Invariant preservation: output always satisfies a postcondition regardless of input
- Commutativity:
f(a, b) === f(b, a) for operations where order should not matter
- No-crash (robustness): function does not throw for any input in the domain
- Monotonicity: if
a <= b, then f(a) <= f(b) for order-preserving functions
- Equivalence:
fastImpl(x) === referenceImpl(x) for optimized implementations
Define input domains. For each property, specify:
- The type and range of valid inputs
- Constraints that inputs must satisfy (e.g., non-empty arrays, positive integers)
- Edge cases that the generator should emphasize (empty strings, zero, max int, Unicode)
Prioritize by risk. Focus property tests on:
- Functions where bugs have high business impact
- Functions with complex branching logic
- Functions that have had historical bugs or regression issues
Report findings. List candidate functions, their properties, and the expected generator configuration.
Phase 2: DEFINE -- Write Property Specifications and Custom Generators
Select the property testing framework. Based on the project's language:
- TypeScript/JavaScript: fast-check
- Python: hypothesis
- Rust: proptest or quickcheck
- Scala: ScalaCheck
- Haskell: QuickCheck
- Java/Kotlin: jqwik
Define custom generators (arbitraries) for domain types. For each domain model:
- Build a generator that produces valid instances with realistic field values
- Add constraints matching the model's validation rules
- Compose generators for nested structures using
map, flatMap, and filter
Write property test specifications. For each property identified in Phase 1:
- State the property as a universally quantified assertion: "For all inputs X satisfying constraint C, property P holds"
- Use the framework's property definition syntax
- Configure iteration count (default: 100 iterations for fast properties, 1000 for critical properties)
Configure shrinking. Ensure the framework's automatic shrinking is enabled:
- Shrinking reduces failing inputs to the minimal counterexample
- Custom generators should support shrinking (use
map over filter where possible, since filter breaks shrinking)
- Set a shrink limit to prevent infinite shrinking on complex inputs
Write seed values for reproducibility. Configure:
- A fixed seed for CI to ensure deterministic reruns
- Seed logging so that any failure can be reproduced exactly
- Replay capability: failed seeds are stored and replayed on subsequent runs
Phase 3: EXECUTE -- Run Property Tests and Collect Counterexamples
Run property tests with verbose output. Execute the test suite and observe:
- Number of test cases generated per property
- Any counterexamples found (failing inputs)
- Shrinking progress (how the framework reduces counterexamples)
Analyze counterexamples. For each failing property:
- Read the shrunk counterexample -- this is the minimal input that violates the property
- Understand why this input causes a failure
- Classify: is this a real bug, or is the property specification too strict?
Reproduce counterexamples deterministically. For each counterexample:
- Record the failing seed value
- Write an explicit example-based test using the shrunk counterexample as a regression test
- This regression test serves as documentation and prevents the same bug from recurring
Handle flaky property tests. If a property test fails intermittently:
- Increase the iteration count to reproduce more reliably
- Check if the property is sensitive to floating-point precision
- Verify that the generator does not produce inputs outside the valid domain
Iterate on generator quality. If the generator frequently produces uninteresting inputs:
- Add bias toward edge cases (empty collections, boundary values)
- Use
filter sparingly (it discards inputs, wasting iterations)
- Prefer
map and flatMap to construct valid inputs directly
Phase 4: ANALYZE -- Diagnose Root Causes and Harden Implementations
Fix bugs exposed by counterexamples. For each real bug found:
- Understand the root cause using the minimal counterexample
- Fix the implementation
- Verify the property now holds (rerun with the same seed)
- Keep the regression test with the explicit counterexample
Strengthen property specifications. After fixing bugs:
- Consider whether additional properties are now testable
- Tighten existing properties if the fix enables stricter invariants
- Add properties for edge cases revealed by the counterexamples
Measure property test effectiveness. Evaluate:
- Number of unique bugs found by property tests vs. example-based tests
- Types of bugs found (off-by-one, overflow, Unicode handling, null handling)
- Generator coverage: what percentage of the input domain is being explored
Integrate property tests into CI. Configure:
- Property tests run on every PR with a moderate iteration count (100)
- Nightly runs use a higher iteration count (10,000) for deeper exploration
- Failed seeds are stored as artifacts for reproduction
Run harness validate. Confirm the project passes all harness checks with property tests in place.
Graph Refresh
If a knowledge graph exists at .harness/graph/, refresh it after code changes to keep graph queries accurate:
harness scan [path]
Harness Integration
harness validate -- Run in ANALYZE phase after property tests are written and bugs are fixed. Confirms project health.
harness check-deps -- Run after DEFINE phase to verify property testing framework is in devDependencies.
emit_interaction -- Used to present counterexample analysis and property specification decisions to the human.
- Grep -- Used in IDENTIFY phase to find pure functions, serializers, validators, and mathematical operations.
- Glob -- Used to catalog existing property test files and domain type definitions.
Success Criteria
- Every function with large input space has at least one property test
- Custom generators produce valid domain objects without relying heavily on
filter
- All counterexamples are investigated: real bugs are fixed, property specs are adjusted for false positives
- Shrunk counterexamples are preserved as explicit regression tests
- Property tests are deterministic in CI (fixed seed) while still exploring randomly in local development
harness validate passes with property tests in place
Examples
Example: fast-check for a TypeScript URL Parser
IDENTIFY -- Properties of a URL parser:
Function: parseUrl(input: string): ParsedUrl
Properties:
1. Round-trip: formatUrl(parseUrl(url)) === url for any valid URL
2. No-crash: parseUrl(arbitrary_string) never throws (returns Result type)
3. Invariant: parsed.protocol is always lowercase
4. Invariant: parsed.host never contains a trailing slash
DEFINE -- Custom generator and property tests:
// tests/property/url-parser.prop.test.ts
import fc from 'fast-check';
import { parseUrl, formatUrl } from '../../src/url-parser';
// Custom generator for valid URLs
const urlArb = fc
.record({
protocol: fc.constantFrom('http', 'https', 'ftp'),
host: fc.domain(),
port: fc.option(fc.integer({ min: 1, max: 65535 }), { nil: undefined }),
path: fc
.array(
fc.stringOf(fc.constantFrom(...'abcdefghijklmnopqrstuvwxyz0123456789-_'.split('')), {
minLength: 1,
})
)
.map((segments) => '/' + segments.join('/')),
})
.map(({ protocol, host, port, path }) => `${protocol}://${host}${port ? ':' + port : ''}${path}`);
describe('URL parser properties', () => {
it('round-trips valid URLs', () => {
fc.assert(
fc.property(urlArb, (url) => {
const parsed = parseUrl(url);
if (!parsed.ok) return false; // skip invalid (generator should not produce these)
return formatUrl(parsed.value) === url;
}),
{ numRuns: 1000, seed: 42 }
);
});
it('never throws on arbitrary string input', () => {
fc.assert(
fc.property(fc.string(), (input) => {
const result = parseUrl(input);
// Must return a Result, never throw
return result.ok === true || result.ok === false;
}),
{ numRuns: 5000 }
);
});
it('always produces lowercase protocol', () => {
fc.assert(
fc.property(urlArb, (url) => {
const parsed = parseUrl(url.toUpperCase());
if (!parsed.ok) return true; // skip failures
return parsed.value.protocol === parsed.value.protocol.toLowerCase();
})
);
});
});
Example: hypothesis for a Python Sorting Algorithm
DEFINE -- Property tests with hypothesis:
# tests/property/test_sort_properties.py
from hypothesis import given, settings, assume
from hypothesis import strategies as st
from myapp.sorting import merge_sort
@given(st.lists(st.integers()))
def test_sort_preserves_length(xs):
"""Sorted output has the same length as input."""
assert len(merge_sort(xs)) == len(xs)
@given(st.lists(st.integers()))
def test_sort_preserves_elements(xs):
"""Sorted output contains exactly the same elements as input."""
assert sorted(merge_sort(xs)) == sorted(xs)
@given(st.lists(st.integers(), min_size=1))
def test_sort_produces_ordered_output(xs):
"""Every element is less than or equal to the next."""
result = merge_sort(xs)
for i in range(len(result) - 1):
assert result[i] <= result[i + 1]
@given(st.lists(st.integers()))
def test_sort_is_idempotent(xs):
"""Sorting an already-sorted list produces the same result."""
twice = merge_sort(once)
assert twice
@settings(max_examples=5000)
@given(st.lists(st.floats(allow_nan=False, allow_infinity=False)))
def test_sort_handles_floats(xs):
"""Sort works correctly with floating-point numbers."""
result = merge_sort(xs)
for i in range(len(result) - 1):
assert result[i] <= result[i + 1]
Rationalizations to Reject
| Rationalization |
Reality |
| "We already have example-based tests that cover the edge cases — property tests would just be redundant." |
Example-based tests cover the cases the author thought of. Property tests cover the cases they did not. The entire value of generative testing is that it explores regions of the input space that human intuition misses — off-by-one errors, Unicode combining characters, signed integer overflow at boundaries. |
| "The generator keeps producing rejected inputs, so I'll just filter more aggressively to make the test pass faster." |
Heavy filter usage is a symptom of a broken generator, not a solution. Each rejected sample wastes an iteration, and filter destroys the shrinking chain, leaving you with an unhelpful counterexample when a bug is found. Rewrite the generator using map and flatMap to construct valid inputs directly. |
| "The counterexample is too strange to be a real-world case — I'll just increase the iteration count so it appears less often." |
A shrunk counterexample that triggers a property failure is a real bug by definition. "Unlikely in practice" is not a property of correctness — the question is whether the invariant holds. If the counterexample is a valid input the function might receive, fix the function. If it is not a valid input, constrain the generator. |
| "This function has too many invariants to specify — I'll just skip property testing and trust the unit tests." |
Complex functions with many invariants are exactly the functions most in need of property testing. High complexity means a larger bug-hiding surface. Start with the most important invariants (no-crash, round-trip, idempotence) rather than attempting to encode all properties at once. |
| "Property tests are too slow — they'll block CI for 10 minutes." |
Run 100 iterations on PR, 10,000 iterations nightly. The CI time argument justifies reducing iteration count, never eliminating property tests entirely. A suite that runs 0 property tests found 0 edge cases. |
Gates
- No property tests without shrinking. If the framework's automatic shrinking is disabled or the generator uses patterns that break shrinking (excessive
filter), counterexamples will be unhelpfully large. Fix the generator to support shrinking.
- No ignoring counterexamples. Every counterexample produced by a property test must be investigated. If it reveals a real bug, fix it. If it is a false positive, adjust the property specification or generator. Never just increase the iteration count to make it "less likely to fail."
- No property tests that always pass trivially. A property that returns
true for every input is useless. Review that properties make substantive assertions. If a property has a return true fallback for most inputs, the generator is producing too many invalid inputs.
- Regression tests are mandatory for counterexamples. Every shrunk counterexample that revealed a bug must be preserved as an explicit example-based test, even after the property test passes. The explicit test serves as documentation and prevents regression.
Escalation
- When the generator cannot produce valid inputs efficiently (> 50% rejection rate): Rewrite the generator to construct valid inputs directly rather than filtering. Use
flatMap to build constrained structures incrementally. If the domain constraints are too complex for a generator, consider whether the function's API needs simplification.
- When a counterexample is too complex to understand even after shrinking: The shrinking strategy may be insufficient for the data type. Write a custom shrinker that targets the specific structure. Alternatively, add intermediate logging to the property to trace which sub-property fails.
- When property tests are too slow for CI (> 5 minutes): Reduce the iteration count for PR runs (100 iterations). Run high-iteration tests (10,000+) as a nightly job. Consider whether some properties can be tested with smaller input ranges without losing coverage.
- When the team debates whether a property is correct: The property may be encoding an assumption that does not hold. Review the specification or domain requirements. If the correct behavior is ambiguous, escalate to product/domain experts before encoding the property in a test.
1---2name: harness-property-test3description: Harness Property Test4metadata:5 source: https://skillmd.com/skills/intense-visions/harness-property-test6---7# Harness Property Test89> Property-based and generative testing with fast-check, hypothesis, and automatic shrinking. Discovers edge cases that example-based tests miss by generating thousands of random inputs and verifying invariants hold for all of them.1011## When to Use1213- Testing functions with large input spaces (parsers, serializers, encoders, validators)14- Verifying mathematical or algebraic properties (commutativity, associativity, round-trip encoding)15- Finding edge cases in data transformation, sorting, or filtering logic16- NOT when testing UI rendering or visual output (use harness-visual-regression instead)17- NOT when testing simple CRUD operations with well-defined inputs (use harness-tdd instead)18- NOT when testing external service integrations (use harness-integration-test instead)1920## Process2122### Phase 1: IDENTIFY -- Discover Testable Properties and Invariants23241. **Catalog candidate functions.** Search for functions that exhibit testable properties:25 - **Pure functions** with deterministic output for given input26 - **Serializers/deserializers** where `decode(encode(x)) === x` (round-trip property)27 - **Sorting/filtering** where output maintains invariants (sorted order, subset relationship)28 - **Validators** where valid input always passes and specific invalid inputs always fail29 - **Mathematical functions** with known algebraic properties30312. **Identify properties for each candidate.** Common property categories:32 - **Round-trip:** `deserialize(serialize(x)) === x` for any valid `x`33 - **Idempotence:** `f(f(x)) === f(x)` (applying the function twice gives the same result)34 - **Invariant preservation:** output always satisfies a postcondition regardless of input35 - **Commutativity:** `f(a, b) === f(b, a)` for operations where order should not matter36 - **No-crash (robustness):** function does not throw for any input in the domain37 - **Monotonicity:** if `a <= b`, then `f(a) <= f(b)` for order-preserving functions38 - **Equivalence:** `fastImpl(x) === referenceImpl(x)` for optimized implementations39403. **Define input domains.** For each property, specify:41 - The type and range of valid inputs42 - Constraints that inputs must satisfy (e.g., non-empty arrays, positive integers)43 - Edge cases that the generator should emphasize (empty strings, zero, max int, Unicode)44454. **Prioritize by risk.** Focus property tests on:46 - Functions where bugs have high business impact47 - Functions with complex branching logic48 - Functions that have had historical bugs or regression issues49505. **Report findings.** List candidate functions, their properties, and the expected generator configuration.5152### Phase 2: DEFINE -- Write Property Specifications and Custom Generators53541. **Select the property testing framework.** Based on the project's language:55 - **TypeScript/JavaScript:** fast-check56 - **Python:** hypothesis57 - **Rust:** proptest or quickcheck58 - **Scala:** ScalaCheck59 - **Haskell:** QuickCheck60 - **Java/Kotlin:** jqwik61622. **Define custom generators (arbitraries) for domain types.** For each domain model:63 - Build a generator that produces valid instances with realistic field values64 - Add constraints matching the model's validation rules65 - Compose generators for nested structures using `map`, `flatMap`, and `filter`66673. **Write property test specifications.** For each property identified in Phase 1:68 - State the property as a universally quantified assertion: "For all inputs X satisfying constraint C, property P holds"69 - Use the framework's property definition syntax70 - Configure iteration count (default: 100 iterations for fast properties, 1000 for critical properties)71724. **Configure shrinking.** Ensure the framework's automatic shrinking is enabled:73 - Shrinking reduces failing inputs to the minimal counterexample74 - Custom generators should support shrinking (use `map` over `filter` where possible, since `filter` breaks shrinking)75 - Set a shrink limit to prevent infinite shrinking on complex inputs76775. **Write seed values for reproducibility.** Configure:78 - A fixed seed for CI to ensure deterministic reruns79 - Seed logging so that any failure can be reproduced exactly80 - Replay capability: failed seeds are stored and replayed on subsequent runs8182### Phase 3: EXECUTE -- Run Property Tests and Collect Counterexamples83841. **Run property tests with verbose output.** Execute the test suite and observe:85 - Number of test cases generated per property86 - Any counterexamples found (failing inputs)87 - Shrinking progress (how the framework reduces counterexamples)88892. **Analyze counterexamples.** For each failing property:90 - Read the shrunk counterexample -- this is the minimal input that violates the property91 - Understand why this input causes a failure92 - Classify: is this a real bug, or is the property specification too strict?93943. **Reproduce counterexamples deterministically.** For each counterexample:95 - Record the failing seed value96 - Write an explicit example-based test using the shrunk counterexample as a regression test97 - This regression test serves as documentation and prevents the same bug from recurring98994. **Handle flaky property tests.** If a property test fails intermittently:100 - Increase the iteration count to reproduce more reliably101 - Check if the property is sensitive to floating-point precision102 - Verify that the generator does not produce inputs outside the valid domain1031045. **Iterate on generator quality.** If the generator frequently produces uninteresting inputs:105 - Add bias toward edge cases (empty collections, boundary values)106 - Use `filter` sparingly (it discards inputs, wasting iterations)107 - Prefer `map` and `flatMap` to construct valid inputs directly108109### Phase 4: ANALYZE -- Diagnose Root Causes and Harden Implementations1101111. **Fix bugs exposed by counterexamples.** For each real bug found:112 - Understand the root cause using the minimal counterexample113 - Fix the implementation114 - Verify the property now holds (rerun with the same seed)115 - Keep the regression test with the explicit counterexample1161172. **Strengthen property specifications.** After fixing bugs:118 - Consider whether additional properties are now testable119 - Tighten existing properties if the fix enables stricter invariants120 - Add properties for edge cases revealed by the counterexamples1211223. **Measure property test effectiveness.** Evaluate:123 - Number of unique bugs found by property tests vs. example-based tests124 - Types of bugs found (off-by-one, overflow, Unicode handling, null handling)125 - Generator coverage: what percentage of the input domain is being explored1261274. **Integrate property tests into CI.** Configure:128 - Property tests run on every PR with a moderate iteration count (100)129 - Nightly runs use a higher iteration count (10,000) for deeper exploration130 - Failed seeds are stored as artifacts for reproduction1311325. **Run `harness validate`.** Confirm the project passes all harness checks with property tests in place.133134### Graph Refresh135136If a knowledge graph exists at `.harness/graph/`, refresh it after code changes to keep graph queries accurate:137138```139harness scan [path]140```141142## Harness Integration143144- **`harness validate`** -- Run in ANALYZE phase after property tests are written and bugs are fixed. Confirms project health.145- **`harness check-deps`** -- Run after DEFINE phase to verify property testing framework is in devDependencies.146- **`emit_interaction`** -- Used to present counterexample analysis and property specification decisions to the human.147- **Grep** -- Used in IDENTIFY phase to find pure functions, serializers, validators, and mathematical operations.148- **Glob** -- Used to catalog existing property test files and domain type definitions.149150## Success Criteria151152- Every function with large input space has at least one property test153- Custom generators produce valid domain objects without relying heavily on `filter`154- All counterexamples are investigated: real bugs are fixed, property specs are adjusted for false positives155- Shrunk counterexamples are preserved as explicit regression tests156- Property tests are deterministic in CI (fixed seed) while still exploring randomly in local development157- `harness validate` passes with property tests in place158159## Examples160161### Example: fast-check for a TypeScript URL Parser162163**IDENTIFY -- Properties of a URL parser:**164165```166Function: parseUrl(input: string): ParsedUrl167Properties:168 1. Round-trip: formatUrl(parseUrl(url)) === url for any valid URL169 2. No-crash: parseUrl(arbitrary_string) never throws (returns Result type)170 3. Invariant: parsed.protocol is always lowercase171 4. Invariant: parsed.host never contains a trailing slash172```173174**DEFINE -- Custom generator and property tests:**175176```typescript177// tests/property/url-parser.prop.test.ts178import fc from 'fast-check';179import { parseUrl, formatUrl } from '../../src/url-parser';180181// Custom generator for valid URLs182const urlArb = fc183 .record({184 protocol: fc.constantFrom('http', 'https', 'ftp'),185 host: fc.domain(),186 port: fc.option(fc.integer({ min: 1, max: 65535 }), { nil: undefined }),187 path: fc188 .array(189 fc.stringOf(fc.constantFrom(...'abcdefghijklmnopqrstuvwxyz0123456789-_'.split('')), {190 minLength: 1,191 })192 )193 .map((segments) => '/' + segments.join('/')),194 })195 .map(({ protocol, host, port, path }) => `${protocol}://${host}${port ? ':' + port : ''}${path}`);196197describe('URL parser properties', () => {198 it('round-trips valid URLs', () => {199 fc.assert(200 fc.property(urlArb, (url) => {201 const parsed = parseUrl(url);202 if (!parsed.ok) return false; // skip invalid (generator should not produce these)203 return formatUrl(parsed.value) === url;204 }),205 { numRuns: 1000, seed: 42 }206 );207 });208209 it('never throws on arbitrary string input', () => {210 fc.assert(211 fc.property(fc.string(), (input) => {212 const result = parseUrl(input);213 // Must return a Result, never throw214 return result.ok === true || result.ok === false;215 }),216 { numRuns: 5000 }217 );218 });219220 it('always produces lowercase protocol', () => {221 fc.assert(222 fc.property(urlArb, (url) => {223 const parsed = parseUrl(url.toUpperCase());224 if (!parsed.ok) return true; // skip failures225 return parsed.value.protocol === parsed.value.protocol.toLowerCase();226 })227 );228 });229});230```231232### Example: hypothesis for a Python Sorting Algorithm233234**DEFINE -- Property tests with hypothesis:**235236```python237# tests/property/test_sort_properties.py238from hypothesis import given, settings, assume239from hypothesis import strategies as st240from myapp.sorting import merge_sort241242@given(st.lists(st.integers()))243def test_sort_preserves_length(xs):244 """Sorted output has the same length as input."""245 assert len(merge_sort(xs)) == len(xs)246247@given(st.lists(st.integers()))248def test_sort_preserves_elements(xs):249 """Sorted output contains exactly the same elements as input."""250 assert sorted(merge_sort(xs)) == sorted(xs)251252@given(st.lists(st.integers(), min_size=1))253def test_sort_produces_ordered_output(xs):254 """Every element is less than or equal to the next."""255 result = merge_sort(xs)256 for i in range(len(result) - 1):257 assert result[i] <= result[i + 1]258259@given(st.lists(st.integers()))260def test_sort_is_idempotent(xs):261 """Sorting an already-sorted list produces the same result."""262 once = merge_sort(xs)263 twice = merge_sort(once)264 assert once == twice265266@settings(max_examples=5000)267@given(st.lists(st.floats(allow_nan=False, allow_infinity=False)))268def test_sort_handles_floats(xs):269 """Sort works correctly with floating-point numbers."""270 result = merge_sort(xs)271 for i in range(len(result) - 1):272 assert result[i] <= result[i + 1]273```274275## Rationalizations to Reject276277| Rationalization | Reality |278| ------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |279| "We already have example-based tests that cover the edge cases — property tests would just be redundant." | Example-based tests cover the cases the author thought of. Property tests cover the cases they did not. The entire value of generative testing is that it explores regions of the input space that human intuition misses — off-by-one errors, Unicode combining characters, signed integer overflow at boundaries. |280| "The generator keeps producing rejected inputs, so I'll just filter more aggressively to make the test pass faster." | Heavy `filter` usage is a symptom of a broken generator, not a solution. Each rejected sample wastes an iteration, and `filter` destroys the shrinking chain, leaving you with an unhelpful counterexample when a bug is found. Rewrite the generator using `map` and `flatMap` to construct valid inputs directly. |281| "The counterexample is too strange to be a real-world case — I'll just increase the iteration count so it appears less often." | A shrunk counterexample that triggers a property failure is a real bug by definition. "Unlikely in practice" is not a property of correctness — the question is whether the invariant holds. If the counterexample is a valid input the function might receive, fix the function. If it is not a valid input, constrain the generator. |282| "This function has too many invariants to specify — I'll just skip property testing and trust the unit tests." | Complex functions with many invariants are exactly the functions most in need of property testing. High complexity means a larger bug-hiding surface. Start with the most important invariants (no-crash, round-trip, idempotence) rather than attempting to encode all properties at once. |283| "Property tests are too slow — they'll block CI for 10 minutes." | Run 100 iterations on PR, 10,000 iterations nightly. The CI time argument justifies reducing iteration count, never eliminating property tests entirely. A suite that runs 0 property tests found 0 edge cases. |284285## Gates286287- **No property tests without shrinking.** If the framework's automatic shrinking is disabled or the generator uses patterns that break shrinking (excessive `filter`), counterexamples will be unhelpfully large. Fix the generator to support shrinking.288- **No ignoring counterexamples.** Every counterexample produced by a property test must be investigated. If it reveals a real bug, fix it. If it is a false positive, adjust the property specification or generator. Never just increase the iteration count to make it "less likely to fail."289- **No property tests that always pass trivially.** A property that returns `true` for every input is useless. Review that properties make substantive assertions. If a property has a `return true` fallback for most inputs, the generator is producing too many invalid inputs.290- **Regression tests are mandatory for counterexamples.** Every shrunk counterexample that revealed a bug must be preserved as an explicit example-based test, even after the property test passes. The explicit test serves as documentation and prevents regression.291292## Escalation293294- **When the generator cannot produce valid inputs efficiently (> 50% rejection rate):** Rewrite the generator to construct valid inputs directly rather than filtering. Use `flatMap` to build constrained structures incrementally. If the domain constraints are too complex for a generator, consider whether the function's API needs simplification.295- **When a counterexample is too complex to understand even after shrinking:** The shrinking strategy may be insufficient for the data type. Write a custom shrinker that targets the specific structure. Alternatively, add intermediate logging to the property to trace which sub-property fails.296- **When property tests are too slow for CI (> 5 minutes):** Reduce the iteration count for PR runs (100 iterations). Run high-iteration tests (10,000+) as a nightly job. Consider whether some properties can be tested with smaller input ranges without losing coverage.297- **When the team debates whether a property is correct:** The property may be encoding an assumption that does not hold. Review the specification or domain requirements. If the correct behavior is ambiguous, escalate to product/domain experts before encoding the property in a test.