cargo_test_support::compare

Function assert_ui

Source
pub fn assert_ui() -> Assert
Expand description

Assertion policy for UI tests

This emphasizes showing as much content as possible at the cost of more brittleness

§Snapshots

Updating of snapshots is controlled with the SNAPSHOTS environment variable:

  • skip: do not run the tests
  • ignore: run the tests but ignore their failure
  • verify: run the tests
  • overwrite: update the snapshots based on the output of the tests

§Patterns

  • [..] is a character wildcard, stopping at line breaks
  • \n...\n is a multi-line wildcard
  • [EXE] matches the exe suffix for the current platform
  • [ROOT] matches paths::root()
  • [ROOTURL] matches paths::root() as a URL

§Normalization

In addition to the patterns described above, text is normalized in such a way to avoid unwanted differences. The normalizations are:

  • Backslashes are converted to forward slashes to deal with Windows paths. This helps so that all tests can be written assuming forward slashes. Other heuristics are applied to try to ensure Windows-style paths aren’t a problem.
  • Carriage returns are removed, which can help when running on Windows.

§Example

assert_e2e().eq(stdout, file!["stderr.term.svg"]);
$ SNAPSHOTS=overwrite cargo test