Crate cli_test_dir [−] [src]
This crate makes it easier to write integration tests for CLI applications. It's based on the "workdir" pattern used by BurntSushi's xsv and ripgrep crates, but packaged in an easy-to-reuse form.
To use this crate, add the following lines to your Cargo.toml
file:
[dev-dependencies]
# You can replace "*" with the current version of this crate.
cli_test_dir = "*"
Then add the following at the top of tests/tests.rs
:
extern crate cli_test_dir;
Once this is done, you can set up a simple test.
use cli_test_dir::TestDir; #[test] fn write_output_file() { let testdir = TestDir::new("mybin", "write_output_file"); let status = testdir.cmd() .arg("-o") .arg("out.txt") .status() .expect("could not run mybin"); assert!(status.success()); testdir.expect_path("out.txt"); }
Contributing
Your feedback and contributions are welcome! Please see GitHub for details.
Structs
TestDir |
This code is inspired by the |