What are Test Cases?
Case is Merit’s way of structuring complex test scenarios with:
- Input parameters
- Expected outputs/references
- Metadata and tags
- Type safety with Pydantic
Basic Case
Define a simple test case:Typed References
Use Pydantic models for type-safe references:Iterating Over Cases
Use@merit.iter_cases to run the same test logic on multiple cases:
Case Tags
Add tags for filtering and organization:Case Metadata
Add arbitrary metadata for test context:Validating Cases
Validate that cases match your function signature:Complete Example
When to Use Cases
UseCase when you have:
- ✅ Many similar tests with different inputs
- ✅ Complex test data that needs structure
- ✅ Tests that need metadata or tags
- ✅ Tests where type safety is important
- ❌ Testing a single scenario
- ❌ Test logic is very different between scenarios
- ❌ Simple assertions are sufficient