docs(test): Add high level example

This commit is contained in:
Ed Page 2024-07-15 16:43:54 -05:00
parent ad6abb54be
commit ca9fc47fe0

View File

@ -16,6 +16,30 @@
//! * This is designed for testing Cargo itself. Use at your own risk.
//! * No guarantee on any stability across versions.
//! * No feature request would be accepted unless proved useful for testing Cargo.
//!
//! # Example
//!
//! ```rust,no_run
//! use cargo_test_support::prelude::*;
//! use cargo_test_support::str;
//! use cargo_test_support::project;
//!
//! #[cargo_test]
//! fn some_test() {
//! let p = project()
//! .file("src/main.rs", r#"fn main() { println!("hi!"); }"#)
//! .build();
//!
//! p.cargo("run --bin foo")
//! .with_stderr_data(str![[r#"
//! [COMPILING] foo [..]
//! [FINISHED] [..]
//! [RUNNING] `target/debug/foo`
//! "#]])
//! .with_stdout_data(str![["hi!"]])
//! .run();
//! }
//! ```
#![allow(clippy::disallowed_methods)]
#![allow(clippy::print_stderr)]