Rust testing library that provides a set of assertions that are similar to built in assert
and assert_eq
but provide more context about the failure and use ANSI terminal colors to format the error messages.
It also includes assert_matches_snapshot!
macro. When first run with K9_UPDATE_SNAPSHOTS=1
it will
save the contents of the passed argument into a __k9_snapshots__/my_test_file/my_test.snap
file, and
for every next run it will compare the passed value with the existing snapshot and fail if the values
are different.
```rust use k9::{assertequal, assertmatchesregex, asserterrmatchesregex, assertmatchessnapshot};
assertequal!(1, 1); assertequal!("one", "one");
struct A { name: &'static str, age: u32, }
let a1 = A { name: "Bob", age: 44 }; let a2 = A { name: "Alice", age: 22 + 22 };
assert_equal!(&a1, &a2);
assertmatchesregex!(a2.name, "Al\w{3}");
assertmatchessnapshot!(format!("{:#?}", a1));
let result: Result<(), &str> = Err("http request fail. code 123"); asserterrmatches_regex!(result, "code 123");
```