Crate k9

Source
Expand description

see https://github.com/aaronabramov/k9 for high level description of the library

Modules§

__macros__
assertions
config
snapshot
string_diff

Macros§

assert_equal
Asserts that two passed arguments are equal. Panics if they’re not, using a pretty printed difference of Debug representations of the passed arguments.
assert_err
Asserts if value is Err(E). panics if it is not
assert_err_matches_regex
Asserts that the passed Result argument is an Err and and the debug string of that error matches provided regex. Regular expressions are compiled using regex crate.
assert_greater_than
Asserts if left is greater than right. panics if they are not
assert_greater_than_or_equal
Asserts if left greater than or equal to right. panics if they are not
assert_lesser_than
Asserts if left is lesser than right. panics if they are not
assert_lesser_than_or_equal
Asserts if left lesser than or equal to right. panics if they are not
assert_matches_regex
Asserts that passed &str matches a regular expression. Regular expressions are compiled using regex crate.
assert_matches_snapshot
Same as snapshot!() macro, but it takes a string as the only argument and stores the snapshot in a separate file instead of inlining it in the source code of the test.
assert_ok
Asserts if value is Ok(T). panics if it is not
make_assertion
snapshot
Serializes the first argument into a string and compares it with the second argument, which is a snapshot string that was automatically generated during previous test runs. Panics if the values are not equal.

Structs§

MultilineString
assert_equal! takes a std::fmt::Debug trait object as an argument which doesn’t work well with multiline strings, since newline characters will be displayed as \n For example this string:
Snap
String with concurrent access. Allows mutation without &mut reference to itself. It makes passing it to different parts of tests easier when performance is not important. Useful for accumulating output from a system under test and later using it with assert_matches_inline_snapshot.