Skip to content

Latest commit

 

History

History
58 lines (46 loc) · 1.49 KB

M_TEST.md

File metadata and controls

58 lines (46 loc) · 1.49 KB

M_TEST - /std/module/test.c

This module is inherited by test files to provide

Lifecycle Functionality

void before_all_tests ()

Run some initialization code which runs once, before all tests are executed.

void before_each_test ()

Run some initialization code which runs before each test is executed.

void after_each_test ()

Run some cleanup code which runs after each test is executed.

void after_all_tests ()

Run some cleanup code which runs once, after all tests are executed.

string *test_order ()

If defined, can be used to instruct D_TEST runner to execute tests in this order.

string *test_ignore () {
    return ::test_ignore() + ({ "local_public_function" });
}

If overridden, can be used instruct D_TEST runner to ignore additional local public functions.

Expect Functionality

void expect (string message, function fn)

Start an expectation of assertions in function fn, while string message contains a human-readable description of what is being tested. fn should consist of a function that returns an array of assert evaluations.

void assert (mixed left, mixed right)

Evaluate an assertion inside of an expectation. left should contain a queried value or result while right should contain the expected answer.

Examples of conditions:

    expect("conditions all pass", (: ({
        assert(1, 1),
        assert_regex("cat", "^.+at"),
        assert_catch((: error("Error") :), "*Error\n"),
    }) :));