What is @repeat?
The@merit.repeat decorator runs a test multiple times to:
- Detect flaky tests
- Test probabilistic systems
- Verify reliability under repeated execution
- Stress test with multiple iterations
Basic Repeat
Run a test multiple times:Minimum Pass Threshold
Allow some failures for probabilistic systems:- LLM outputs with inherent randomness
- Systems with acceptable error rates
- Network calls with occasional failures
Detecting Flakiness
Find unreliable tests:With Parametrization
Combine repeat with parameters:Stress Testing
Test under load:Probabilistic Assertions
Test systems with randomness:Real-World Examples
Testing LLM Consistency
Testing Cache Reliability
Testing Concurrent Access
Testing Model Accuracy Threshold
When to Use Repeat
Use@merit.repeat when:
- ✅ Testing probabilistic or random systems
- ✅ Detecting flaky tests
- ✅ Verifying consistency across iterations
- ✅ Testing reliability under repeated load
- ✅ Validating systems with acceptable error rates
- ❌ Test is deterministic and fast
- ❌ Each iteration is expensive (time/cost)
- ❌ Test is already stable and proven
Repeat vs Parametrize
Repeat - Same inputs, multiple executions:Configuration (TODO)
TODO: Document repeat configuration options Expected options:- Parallel execution of iterations
- Stop on first failure vs run all
- Reporting individual iteration results