tinytest 0.1.1

Write more compact unit tests with a small macro.
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented1 out of 1 items with examples
  • Size
  • Source code size: 5.49 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 91.41 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 7s Average build duration of successful builds.
  • all releases: 7s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Alonely0/tinytest
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Alonely0

Usage

use tinytest::unit_test;

unit_test!(test1, || some_function_in_scope("test").unwrap(), "expected output")

automatically gets translated in compile time to a standard test:

#[cfg(test)]
mod test1 {
    use super::*;

    #[test]
    fn tiny_test() {
        assert_eq!(some_function_in_scope("test").unwrap(), "expected output");
    }
}

the same applies to this larger closure:

use tinytest::unit_test;

unit_test!(test2, || {
    let mut c = some_function_in_scope("test").unwrap().chars()
    c.next();
    c.next_back();
    (
        c.collect::<String>(),
        some_other_function_in_scope(73)
    )
}, (
    "expected output".to_string(),
    21
    )
)

that translates to:

#[cfg(test)]
mod test2 {
    use super::*;

    #[test]
    fn tiny_test() {
        assert_eq!(
            {
                let mut c = some_function_in_scope("test").unwrap().chars()
                c.next();
                c.next_back();
                (
                    c.collect::<String>(),
                    some_other_function_in_scope(73)
                )
            }, (
                "expected output".to_string(),
                21
            )
        );
    }
}