Crate cargo_test_support

Source
Expand description

§Cargo test support.

See https://rust-lang.github.io/cargo/contrib/ for a guide on writing tests.

There are two places you can find API documentation

This crate is maintained by the Cargo team, primarily for use by Cargo and not intended for external use. This crate may make major changes to its APIs or be deprecated without warning.

§Example

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();
}

Modules§

  • Routines for comparing and diffing output.
  • Support for testing using Docker containers.
  • Support for cross-compile tests with the --target flag.
  • diff 🔒
    A simple Myers diff implementation.
  • Git Testing Support
  • Helpers for testing cargo install
  • Access common paths and manipulate the filesystem
  • Helpers for testing cargo package / cargo publish
  • Interact with the TestRegistry
  • Common executables that can be reused by various tests.

Macros§

  • Declare an expected value for an assert from a file
  • Declare an expected value from within Rust source
  • Unwrap a Result with a useful panic message

Structs§

Traits§

Functions§

Attribute Macros§