#unit-testing

lazytest

Reduces the boilerplate required for simple unit tests

3 releases

0.1.2 May 26, 2024
0.1.1 May 25, 2024
0.1.0 May 24, 2024

#334 in Testing

22 downloads per month

MIT-0 license

4KB

lazytest

Provides a macro which reduces the boilerplate required for simple unit tests.

Usage

Given the function:

pub fn answer() -> usize {
    42
}

These are equivalent:

use lazytest::lazytest;

lazytest! {
    check_answer {
        assert_eq!(answer(), 42);
    }
}
#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn check_answer() {
        assert_eq!(answer(), 42);
    }
}

lib.rs:

Provides the [lazytest] macro to reduce the amount of code needed to write unit tests.

No runtime deps