This repository was archived by the owner on Dec 29, 2021. It is now read-only.
File tree 2 files changed +21
-6
lines changed
2 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -283,11 +283,12 @@ impl Assert {
283
283
}
284
284
}
285
285
286
+ /// Assertions for command output.
286
287
#[ derive( Debug ) ]
287
288
pub 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 ,
291
292
}
292
293
293
294
impl OutputAssertionBuilder {
Original file line number Diff line number Diff line change 67
67
//! # fn main() {
68
68
//! assert_cmd!(cat "non-existing-file")
69
69
//! .fails()
70
- //! .and()
71
- //! .stderr().contains("non-existing-file")
72
70
//! .unwrap();
73
71
//! # }
74
72
//! ```
78
76
//! - Use `fails_with` to assert a specific exit status.
79
77
//! - There is also a `succeeds` method, but this is already the implicit default
80
78
//! and can usually be omitted.
81
- //! - We can inspect the output of **stderr** with `stderr().contains` and `stderr().is`.
82
79
//! - The `and` method has no effect, other than to make everything more readable.
83
80
//! Feel free to use it. :-)
84
81
//!
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
+ //!
85
98
//! ## Assert CLI Crates
86
99
//!
87
100
//! If you are testing a Rust binary crate, you can start with
@@ -119,3 +132,4 @@ mod diff;
119
132
120
133
mod assert;
121
134
pub use assert:: Assert ;
135
+ pub use assert:: OutputAssertionBuilder ;
You can’t perform that action at this time.
0 commit comments