pub struct TestConfig<Cmd = Command> { /* private fields */ }
Available on crate feature test only.
Expand description

Testing configuration.

Examples

See the module docs for the examples of usage.

Implementations

Tests a snapshot at the specified path with the provided inputs.

If the path is relative, it is resolved relative to the current working dir, which in the case of tests is the root directory of the including crate (i.e., the dir where the crate manifest is located). You may specify an absolute path using env vars that Cargo sets during build, such as env!("CARGO_MANIFEST_DIR").

Similar to other kinds of snapshot testing, a new snapshot will be generated if there is no existing snapshot or there are mismatches between inputs or outputs in the original and reproduced transcripts. This new snapshot will have the same path as the original snapshot, but with the .new.svg extension. As an example, if the snapshot at snapshots/help.svg is tested, the new snapshot will be saved at snapshots/help.new.svg.

Generation of new snapshots will only happen if the svg crate feature is enabled (which it is by default), and if the update mode is not UpdateMode::Never, either because it was set explicitly or inferred from the execution environment.

The snapshot template can be customized via Self::with_template().

Panics
  • Panics if there is no snapshot at the specified path, or if the path points to a directory.
  • Panics if an error occurs during reproducing the transcript or processing its output.
  • Panics if there are mismatches between inputs or outputs in the original and reproduced transcripts.

Tests the transcript. This is a lower-level alternative to Self::test().

Panics
  • Panics if an error occurs during reproducing the transcript or processing its output.
  • Panics if there are mismatches between outputs in the original and reproduced transcripts.

Tests the transcript and returns testing stats together with the reproduced Transcript. This is a lower-level alternative to Self::test().

Errors
  • Returns an error if an error occurs during reproducing the transcript or processing its output.

Creates a new config.

Panics
  • Panics if the svg crate feature is enabled and the TERM_TRANSCRIPT_UPDATE variable is set to an incorrect value. See UpdateMode::from_env() for more details.

Sets the matching kind applied.

Sets coloring of the output.

On Windows, color_choice has slightly different semantics than its usage in the termcolor crate. Namely, if colors can be used (stdout is a tty with color support), ANSI escape sequences will always be used.

Configures test output.

Available on crate feature svg only.

Sets the template for rendering new snapshots.

Available on crate feature svg only.

Overrides the strategy for saving new snapshots for failed tests.

By default, the strategy is determined from the execution environment using UpdateMode::from_env().

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.