Expand description
Companion crate to ‘bintest’ and ’testcall’, implements facilities for running tests in directories. The testcall crate uses this to build tests and assertions on top of the commands created by bintest. The testpath crate crate lets you run test in specially created temporary directories to provide an filesystem environment for tests.
§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§
- SubPath
- A Path that lives within a TestPath and must not outlive it.
- Temp
DirCleanup - Augment a TempDir with a custom callback function that can do additional cleanup work (like unmounting filesystem etc.)
Traits§
- Fixtures
- Trait for test directoy objects
- Path
Assertions - Assertions on content of a TestPath
- Test
Path - Trait for test directoy objects