This is an "experts only" module that exposes functions needed to run and
display tests. A typical user will use an existing runner library for Node or
the browser, which is implemented using this interface. A list of these runners
can be found in the README.
Convert a Test into SeededRunners.
In order to run any fuzz tests that the Test may have, it requires a default run count as well
as an initial Random.Pcg.Seed. 100 is a good run count. To obtain a good random seed, pass a
random 32-bit integer to Random.Pcg.initialSeed. You can obtain such an integer by running
Math.floor(Math.random()*0xFFFFFFFF) in Node. It's typically fine to hard-code this value into
your Elm code; it's easy and makes your tests reproducible.
Return Nothing if the given Expectation is a pass.
If it is a fail, return a record containing the failure message,
along with the given inputs if it was a fuzz test. (If no inputs were involved,
the record's given field will be Nothing).
For example, if a fuzz test generates random integers, this might return
{ message = "it was supposed to be positive", given = "-1" }
getFailure (Expect.fail "this failed")
-- Just { message = "this failed", given = "" }
getFailure (Expect.pass)
-- NothingDetermine if an expectation was created by a call to Test.todo. Runners
may treat these tests differently in their output.
A standard way to format descriptions and test labels, to keep things consistent across test runner implementations.
The HTML, Node, String, and Log runners all use this.
What it does:
Example:
[ "the actual test that failed"
, "nested description failure"
, "top-level description failure"
]
|> formatLabels ((++) "↓ ") ((++) "✗ ")
{-
[ "↓ top-level description failure"
, "↓ nested description failure"
, "✗ the actual test that failed"
]
-}These functions give you the ability to run fuzzers separate of running fuzz tests.
A Shrinkable a is an opaque type that allows you to obtain a value of type
a that is smaller than the one you've previously obtained.
Given a fuzzer, return a random generator to produce a value and a Shrinkable. The value is what a fuzz test would have received as input.
Given a Shrinkable, attempt to shrink the value further. Pass False to
indicate that the last value you've seen (from either fuzz or this function)
caused the test to fail. This will attempt to find a smaller value. Pass
True if the test passed. If you have already seen a failure, this will attempt
to shrink that failure in another way. In both cases, it may be impossible to
shrink the value, represented by Nothing.
A function which, when evaluated, produces a list of expectations. Also a list of labels which apply to this outcome.