purescript-test-unit
An asynchronous unit test runner for PureScript.
QuickCheck
purescript-quickcheck
tests can be run using the functions in the Test.Unit.QuickCheck
module. It exports two functions, quickCheck
and quickCheck'
,
which work like their QuickCheck counterparts, except they produce
Test
actions so they integrate cleanly with Test-Unit.
module Test.Main where
import Prelude
import Test.Unit (test)
import Test.Unit.Main (runTest)
import Test.Unit.QuickCheck (quickCheck)
import Test.QuickCheck (Result(), (===))
theCommutativeProperty :: Int -> Int -> Result
theCommutativeProperty a b = (a + b) === (b + a)
main = runTest do
test "the commutative property" do
quickCheck theCommutativeProperty
Output Formats
The Test.Unit.Main.runTest
function will default to simple output of
test results using console.log
(the
Test.Unit.Output.Simple.runTest
test runner). If you’re running on
an ANSI colour capable terminal, it will use the
Test.Unit.Output.Fancy.runTest
test runner, which gets a little more
colourful.
Additionally, if Test.Unit.Main.runTest
notices the word tap
or
--tap
on its command line, it will pick the
Test.Unit.Output.TAP.runTest
test runner, which outputs test results
using the TAP format. A number of TAP
consumers are
available on NPM
to transform the test output. For instance, you could install the
tap-spec and run your tests
like this: pulp test tap | tap-spec
.
You can also specify your own test runner using the
Test.Unit.Main.runTestWith
function, which takes a test runner as
its first argument. So, if you want to force the TAP test runner,
instead of main = runTest do ...
you could use main = runTestWith
Test.Unit.Output.TAP.runTest do ...
. You could also supply your own
custom test runner - study one of the existing test runners to learn
how.