Module assert_cmd::cargo[][src]

Simplify running bins in a Cargo project.

CommandCargoExt is an extension trait for Command to easily launch a crate's binaries.

In addition, the underlying functions for looking up the crate's binaries are exposed to allow for optimizations, if needed.

Examples

Simple case:

use assert_cmd::prelude::*;

use std::process::Command;

Command::main_binary()
    .unwrap()
    .unwrap();

For caching to minimize cargo overhead or customize the build process, see escargot.

This example is not tested
use assert_cmd::prelude::*;
use escargot;

use std::process::Command;

let bin_under_test = escargot::CargoBuild::new()
    .bin("bin_fixture")
    .current_release()
    .current_target()
    .run()
    .unwrap();
bin_under_test.command()
    .unwrap();

Tip: Use lazy_static to cache bin_under_test across test functions.

Structs

CargoError

Error when finding crate binary.

Traits

CommandCargoExt

Create a Command for a bin in the Cargo project.

Functions

cargo_bin_path [
Deprecated
]

Get the path to the specified binary of the current crate.

cargo_example_path [
Deprecated
]

Get the path to the specified example of the current crate.

main_binary_path [
Deprecated
]

Get the path to the crate's main binary.