This repository was archived by the owner on Dec 29, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +21
-6
lines changed Expand file tree Collapse file tree 2 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -283,11 +283,12 @@ impl Assert {
283283 }
284284}
285285
286+ /// Assertions for command output.
286287#[ derive( Debug ) ]
287288pub struct OutputAssertionBuilder {
288- pub assertion : Assert ,
289- pub kind : OutputKind ,
290- pub expected_result : bool ,
289+ assertion : Assert ,
290+ kind : OutputKind ,
291+ expected_result : bool ,
291292}
292293
293294impl OutputAssertionBuilder {
Original file line number Diff line number Diff line change 6767//! # fn main() {
6868//! assert_cmd!(cat "non-existing-file")
6969//! .fails()
70- //! .and()
71- //! .stderr().contains("non-existing-file")
7270//! .unwrap();
7371//! # }
7472//! ```
7876//! - Use `fails_with` to assert a specific exit status.
7977//! - There is also a `succeeds` method, but this is already the implicit default
8078//! and can usually be omitted.
81- //! - We can inspect the output of **stderr** with `stderr().contains` and `stderr().is`.
8279//! - The `and` method has no effect, other than to make everything more readable.
8380//! Feel free to use it. :-)
8481//!
82+ //! ## stdout / stderr
83+ //!
84+ //! You can add assertions on the content of **stdout** and **stderr**. They
85+ //! can be mixed together or even multiple of one stream can be used.
86+ //!
87+ //! ```rust
88+ //! # #[macro_use] extern crate assert_cli;
89+ //! # fn main() {
90+ //! assert_cmd!(echo "Hello world! The ansswer is 42.")
91+ //! .stdout().contains("Hello world")
92+ //! .stdout().contains("42")
93+ //! .stderr().is("")
94+ //! .unwrap();
95+ //! # }
96+ //! ```
97+ //!
8598//! ## Assert CLI Crates
8699//!
87100//! If you are testing a Rust binary crate, you can start with
@@ -119,3 +132,4 @@ mod diff;
119132
120133mod assert;
121134pub use assert:: Assert ;
135+ pub use assert:: OutputAssertionBuilder ;
You can’t perform that action at this time.
0 commit comments