Struct retest::Test[][src]

pub struct Test { /* fields omitted */ }
Expand description

Represents a single test which can be generated or retested.

Create a new test using new(). Override its defaults using the builder methods, and finally call build().

New Tests should be passed to the Plan::push() method.

See also the builders example.

Implementations

Returns a new Test.

Creates a new Test with the application to test set to the given app.

The given app should either be in the PATH or should include a path. For example: Path::new(env!("CARGO_TARGET_DIR")).join("myapp.exe").

The Test’s defaults are for an expected error code/error level of 0, no arguments for the application to test, no stdin to be fed into the application, no stdout to be captured from the application, and for expected and actual outputs to be compared using the DiffKind that retest itself determines.

All the defaults can be overridden using the Test’s methods.

Sets the command line arguments to be passed to the application to test.

If one of these arguments is the filename of a file which you want to generate or retest, then its name must be prefixed with $OUT_PATH, e.g., .args(&["-o", "$OUT_PATH/123.png"]). When generating, $OUT_PATH is replaced by the expected path, and when retesting by the actual path.

Note that retest can compare either a single output file or the application to test’s stdout (captured to a file), but not both at the same time. If you need to test both, then create two separate tests. This is because each comparison may need to be done differently. For example the output file might be compared as an image and the stdout as text.

See also stdout().

Sets the Test’s name.

This is used when logging passed tests and in all cases when logging output is at the “debug” level.

Sets the expected exit code/error level when the application to test is run.

Sets how long (in seconds) to wait before running the application to test.

The default is 0.0, i.e., don’t wait.

This option can be useful if a test sometimes “outruns” the operating system causing it to needlessly fail, and which can be cured by a small wait.

Sets the raw bytes to be passed to the application to test’s stdin.

Note that if you use this method and subsequently use the Plan::rt() method, the returned retest plan file (.rt) format string will have a STDIN placeholder for each test this method is used on. For example:

STDIN: ///87 raw bytes///

This is because the bytes are fed directly into the method rather than read from a file as happens when using a retest plan file (.rt).

Sets the name of the file to capture the application to test’s stdout to.

This file will be written to the expected path when generating, or to the actual path when retesting.

Note that retest can compare either a single output file or the application to test’s stdout (captured to a file), but not both at the same time. If you need to test both, then create two separate tests. This is because each comparison may need to be done differently. For example the output file might be compared as an image and the stdout as text.

See also args().

Sets how retest comparisons between expecteds and actuals is done.

By default, the Plan::retest() method guesses what kind of comparison to do when comparing an expected output with an actual output during a retest run.

For files with no suffix it assumes DiffKind::Binary, and for files with suffix .jsn or .json it assumes DiffKind::Json (and compares the JSON data, ignoring irrelevant whitespace). For common image formats it assumes DiffKind::Image and compares pixel for pixel; otherwise it assumes DiffKind::Text and compares text (but ignores line-endings).

You can force retest to use the comparison mode of your choice for a particular test by passing a DiffKind to this method.

Or you can make Plan::retest() use an external tool to do the comparison by passing the tool’s name (e.g., pass DiffKind::custom("diff") on Unix, to use the diff tool). The tool must return 0 if the compared files are (or are considered to be) the same, or non-zero otherwise.

Or you can force retest not to compare output (i.e., if you only want to check the exit status/error level) by passing DiffKind::No.

Sets the command line arguments to pass to an external tool if one is specified using the diff() method.

Normally you will need at least two arguments giving the names of the two files to compare, e.g., ["$EXPECTED_PATH/test05.dat", "$ACTUAL_PATH/test05.dat"]. At runtime these paths are replaced with rt_expected and rt_actual as appropriate, or to the path(s) set using Plan::expected_path() or Plan::actual_path().

Returns the built Test ready to be passed to Plan::push().

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

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.