[][src]Struct retest::Plan

pub struct Plan { /* fields omitted */ }

Holds one or more Tests which can be used to generate expected files or to retest by creating actual files and comparing them with the expecteds.

To create a new Plan from a retest plan file (.rt), use the new_from_rt() or new_from_rt_filtered() methods.

See also the retest plan file example.

To create a new Plan programmatically, use new() to create an empty Plan, and then the builder methods. For example, use expected_path() and actual_path() to set non-default paths. Then for each test, call push(). And finally, call build().

See also the builders example.

Once a Plan has been created either from a .rt file or using the builder methods, you can generate or retest by using apply(), generate(), or retest().

Methods

impl Plan[src]

pub fn new() -> Plan[src]

Returns a new empty Plan.

Creates a new Plan with a default expected path of rt_expected and a default actual path of rt_actual (i.e., both are relative to the current folder), and that contains no tests. When each Test is run its app is assumed to be in the PATH or to include a path. For example, you could do something like this:

This example is not tested
let app = Path::new(env!("CARGO_TARGET_DIR")).join("myapp.exe");
let plan = Plan::new()
    .push(Test::new(&app) // etc.

The Plan returned is expected to be used with the Plan builder methods. For example, use expected_path() or actual_path() to set non-default paths. For every test required, call push() giving it a newly built Test. And finally, call build() to make the Plan ready for use.

Note that plans can also be created by reading a retest plan file (.rt) using the new_from_rt() or new_from_rt_filtered() methods.

pub fn expected_path<P: AsRef<Path>>(&mut self, expected_path: P) -> &mut Self[src]

Sets the Plan's expected path to the one given.

The default expected path is rt_expected in the current folder.

pub fn actual_path<P: AsRef<Path>>(&mut self, actual_path: P) -> &mut Self[src]

Sets the Plan's actual path to the one given.

The default actual path is rt_actual in the current folder.

pub fn push(&mut self, test: Test) -> &mut Self[src]

Appends a new Test to the plan.

The first test added is number 1, the second 2, and so on. The number is used when logging passed, failed, or errored tests.

pub fn build(&mut self) -> Self[src]

Returns the Plan you've built and on which you can call generate(), retest(), or apply().

impl Plan[src]

pub fn new_from_rt<P: AsRef<Path>>(filename: P) -> XResult<Plan>[src]

Returns a Plan on which you can call generate(), retest(), or apply().

Reads the test plan and all the tests from the file with the given filename which must be in retest plan file (.rt) format, and returns the corresponding Plan.

Note that plans can also be created programatically using new() and the Plan builder methods.

pub fn new_from_rt_filtered<P: AsRef<Path>>(
    filename: P,
    numbers: &BTreeSet<u32>
) -> XResult<Plan>
[src]

Returns a Plan on which you can call generate(), retest(), or apply().

Reads the test plan from the file with the given filename which must be in retest plan file (.rt) format, and returns the corresponding Plan. Only those tests whose numbers appear in the given numbers set are included in the Plan.

Note that plans can also be created programatically using new() and the Plan builder methods.

impl Plan[src]

pub fn apply(&self) -> XResult<Counts>[src]

Returns a Counts holding the number of tests, passes, fails, and errors.

If the RETEST_GENERATE environment variable is present and set to 1, this method calls generate(); otherwise it calls retest().

pub fn retest(&self) -> XResult<Counts>[src]

Returns a Counts holding the number of tests, passes, fails, and errors.

Runs all the tests in the Plan. For each test, providing the exit code/error level is what's expected, any test output is saved to the actual path and then the original output that was generated previously in the expected path is compared with the newly saved output.

During retesting, logging output is produced (or not) depending on the logger you are using and the logging level you have set.

All the fields in the returned Counts are used (although some could be 0).

pub fn generate(&self) -> XResult<Counts>[src]

Returns a Counts holding the number of tests and fails.

Runs all the tests in the Plan. For each test, any test output is saved to the expected path.

During generating, logging output is produced (or not) depending on the logger you are using and the logging level you have set.

Only the total and failed fields in the returned Counts are used.

impl Plan[src]

pub fn is_empty(&self) -> bool[src]

Returns true if this Plan has no tests; otherwise returns false.

pub fn len(&self) -> usize[src]

Returns how many tests this Plan has (which could be 0).

pub fn rt(&self) -> String[src]

Returns this test Plan (and any tests it contains) as a single string in retest plan file (.rt) format.

Note that if the plan is created using Plan::new() and if one or more of builders' tests (created using Tests) uses the stdin_redirect() method, the relevant plan's tests will have STDIN placeholders like this example:

This example is not tested
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).

Trait Implementations

impl Debug for Plan[src]

Auto Trait Implementations

impl Send for Plan

impl Unpin for Plan

impl Sync for Plan

impl UnwindSafe for Plan

impl RefUnwindSafe for Plan

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> SetParameter for T