Elm Test Distributions
3 days ago
- #elm
- #testing
- #property-based-testing
- Property-based tests can miss interesting cases if the distribution of generated values is not carefully considered.
- Using `Fuzz.examples` allows visual inspection of generated values to ensure coverage.
- The `Test.reportDistribution` function provides a histogram of how often different cases are tested.
- `Test.expectDistribution` can enforce minimum coverage requirements for specific test cases.
- Labeling examples with `Fuzz.labelExamples` helps identify which cases are being tested.
- Combinations of labels can overlap, and more specific combinations take precedence in counting.
- Enforcing distributions with `Test.expectDistribution` can fail tests if coverage is insufficient, even if the test logic passes.
- The Elm testing library's `Test.Distribution` module is inspired by Haskell's QuickCheck and similar tools.
- John Hughes' talk on property-based testing provides deeper insights into effective test case generation.