Cargo allows us to execute a few different kinds of tests, including integration and unit. For now we'll talk about integration tests for our CLI. Integration tests live in /tests
and only have access to the public interface of a crate.
In this case, we'll run the garden
binary using assert_cmd
and assert various things about the execution and output. For example, that the binary exits successfully and that stderr has no output.
cargo test
allows us to run all tests.
To restrict the number of tests that run to only the two that work, we can use cargo test help
to restrict cargo to only running tests that match the keyword "help", or use #[ignore]
on a test we want to ignore.
The third test will be ignored because we have yet to build out our functionality.