Crate testpath[][src]

Expand description

Companion crate to ‘bintest’ and ’testcall’, implements facilities for running tests in directories.

Description

Allows creating of (temporary) test directories, optionally with a custom callback for cleanup. Populating these with content for testing and provide assertion to validate the content.

Example

fn test_something() {
    let tmpdir = TempDir::new().expect("TempDir created");
    tmpdir.create_file("path/to/testfile", "Hello File!".as_bytes());
    tmpdir
        .sub_path("path/to/testfile")
        .assert_utf8("Hello File!");
}

Panics vs. Results

‘testpath’ is made explicitly for writing tests. To ease this it prefers aborting by panic over error handling. When anything goes wrong the test is aborted and the cause is reported.

Structs

A Path that lives within a TestPath and must not outlive it.

Augment a TempDir with a custom callback function that can do additional cleanup work (like unmounting filesystem etc.)

Traits

Trait for test directoy objects

Assertions on content of a TestPath

Trait for test directoy objects