Suite

A simple test runner

The functions in this module let you build up trees of tests, and run them.

import M "mo:matchers/Matchers";
import T "mo:matchers/Testable";
import Suite "mo:matchers/Suite";

let suite = Suite.suite("My test suite", [
    Suite.suite("Nat tests", [
        Suite.test("10 is 10", 10, M.equals(T.nat(10))),
        Suite.test("5 is greater than three", 5, M.greaterThan<Nat>(3)),
    ])
]);
Suite.run(suite);

type Suite = {#node : { name : Text; children : [Suite] }; #test : { name : Text; test : () -> ?Matchers.Description }}

A collection of tests to be run together

public func run(suite : Suite)

Runs a given suite of tests. Will exit with a non-zero exit code in case any of the tests fail.

public func suite(suiteName : Text, suiteChildren : [Suite]) : Suite

Constructs a test suite from a name and an Array of

public func test<A>(
  testName : Text,
  item : A,
  matcher : Matchers.Matcher<A>
) : Suite

Constructs a single test by matching the given item against a matcher.

public func testLazy<A>(
  testName : Text,
  mkItem : () -> A,
  matcher : Matchers.Matcher<A>
) : Suite

Like test, but accepts a thunk mkItem that creates the value to match against. Use this to delay the evaluation of the to be matched value until the tests actually run.