Skip to content

Latest commit

 

History

History
45 lines (29 loc) · 1.3 KB

README.md

File metadata and controls

45 lines (29 loc) · 1.3 KB

Usage

Just use the module and have it be accessible to the load path:

use tester::*;
mod tester;

Syntax

describe!("module", {
  test!("function", {
    should!("do something", {
      must!(foo(1, 2) eq 5);
    })
  })
})

The describe macro establishes a context for a module with test macros defining each function. Tests are defined by should macros that should describe what behavior is being reflected by the function.

The must macros are assertions. The order should be: must!(computed eq expected);. For example, to test the function foo: must!(foo() eq 5); There are special considerations for floating point: must!(pi() near 3.1415); which tests that the given value is within 0.00001 to account for natural floating point error. You can specify the amount of tolerance: must!(pi() near 3.1415 within 0.001);

License

Public domain or CC0.

Output

Successful output will look like this:

output screenshot

A failure will look like this:

output screenshot

It will report the expected result and the given result. No frills.

TODO

  • Randomize order of tests
  • Better error reporting (line number for instance)