Skip to content

Rust testing framework in the public domain based on existing behavioral testing frameworks. Simple and no-frills.

License

Notifications You must be signed in to change notification settings

wilkie/rust-testing-microframework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

About

Rust testing framework in the public domain based on existing behavioral testing frameworks. Simple and no-frills.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published