testbldr

Types

A test has a name and a body (a function which returns a TestOutcome)

pub type Test {
  Test(name: String, test_function: fn() -> TestOutcome)
}

Constructors

  • Test(name: String, test_function: fn() -> TestOutcome)

A test can either pass or fail with a given reason

pub type TestOutcome {
  Pass
  Fail(msg: String)
}

Constructors

  • Pass
  • Fail(msg: String)

Configuration for how to run a set of tests

pub opaque type TestRunner

Functions

pub fn display_ratio_using(
  runner: TestRunner,
  printer printer: fn(Int, Int) -> String,
) -> TestRunner

How to print the ratio of passing to failing tests

pub fn display_test_outcome_using(
  runner: TestRunner,
  printer printer: fn(String, TestOutcome) -> String,
) -> TestRunner

How to print an individual test outcome

pub fn include_passing_tests_in_output(
  runner: TestRunner,
  input: Bool,
) -> TestRunner

Set whether to include passing tests in the output

pub fn named(name: String, new_test: fn() -> TestOutcome) -> Test

Creates a new test with the given name

pub fn output_results_to_file(
  runner: TestRunner,
  path path: String,
) -> TestRunner

Write the test run output to a file

pub fn output_results_to_stdout(runner: TestRunner) -> TestRunner

Write the test run output to stdout

pub fn run(runner: TestRunner, tests: List(Test)) -> Nil

Runs a list of tests with the provided test runner

pub fn test_runner_default() -> TestRunner

Create a new test runner with the default configuration

Search Document