[−][src]Macro k9::assert_matches_snapshot
Formats passed value and asserts that it matches existing snaphot.
If snapshot file for this test does not exist, test can be run with K9_UPDATE_SNAPSHOTS=1
environment variable to either create or replace existing snapshot file.
Snapshots will be written into __k9_snapshots__
directory next to the test file.
#[test] fn my_test() { struct A { name: &'a str, age: u32 } let a = A { name: "Lance", age: 9 }; // When first run with `K9_UPDATE_SNAPSHOTS=1` it will // create `__k9_snapshots__/my_test_file/my_test.snap` file // with contents being the serialized value of `a`. // Next time the test is run, if the newly serialized value of a // is different from the value of that snapshot file, the assertion // will fail. assert_matches_snapshot!(a); }