#test #assert

assertify

Make tests from simple expressions without boilerplate

2 unstable releases

0.6.0 Dec 11, 2019
0.5.0 Dec 10, 2019

#178 in Testing


Used in htmlize

MIT/Apache

9KB
86 lines

Assertify and Testify

This provides two convenience macros to make tests from simple Rust expressions.

testify!(name, expr)

Generates a test function named name that asserts that expr is true.

testify!(concat_literals, concat("a", "b") == "ab");

assertify!(expr)

Generates an assertion for expr with a friendly failure message.

#[test]
fn simple_eq() {
    assertify!(1 + 2 == 0);
}
---- tests::fail_simple_eq stdout ----
thread 'tests::simple_eq' panicked at 'failed: 1 + 2 == 0
  actual:      3
  expected: == 0
', src/lib.rs:96:9

License

This project dual-licensed under the Apache 2 and MIT licenses. You may choose to use either.

Contributions

Unless you explicitly state otherwise, any contribution you submit as defined in the Apache 2.0 license shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

This provides two convenience macros to make tests from simple expressions.

# #[macro_use] extern crate assertify;
# fn main() {}
testify!(add_one_two, 1 + 2 == 3);
#[test]
fn add_one_two() {
    assertify!(1 + 2 == 3);
}

Dependencies

~345–780KB
~19K SLoC