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

WARNING: You might not want to use this outside of Cargo.

  • 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

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§