Test.Distribution
Distribution
type alias ExpectedDistribution =
ExpectedDistribution
Your input distribution requirement for the fuzzer used in a test.
For example, "this test shouldn't ever receive strings of length < 3 as an input" or "at least 30% of the test input trees should be balanced".
atLeast :
Float -> ExpectedDistribution
A requirement that a given value class should happen at least N% of the time in a given test.
The example below says that at least 30% of the fuzz test inputs should be multiples of 3.
fuzzWith
{ runs = 10000
, distribution =
expectDistribution
[ ( atLeast 30, "multiple of 3", \n -> (n |> modBy 3) == 0 )
]
}
zero :
ExpectedDistribution
A requirement that a given value class should never happen in a given test.
moreThanZero :
ExpectedDistribution
A requirement that a given value class should happen at least once in a given test.
type DistributionReport
= NoDistribution
| DistributionToReport ({ distributionCount : Dict (Array String) Int, runsElapsed : Int })
| DistributionCheckSucceeded ({ distributionCount : Dict (Array String) Int, runsElapsed : Int })
| DistributionCheckFailed ({ distributionCount : Dict (Array String) Int, runsElapsed : Int, badLabel : String, badLabelPercentage : Float, expectedDistribution : String })
A result of a distribution check.
Get it from your Expectation
with Test.Runner.getDistributionReport
.
distributionReportTable :
{ a | runsElapsed : Int, distributionCount : Dict (Array String) Int } -> String
Prettyprints the record inside DistributionReport
into a table with histograms.