pub trait CommandCargoExtwhere
    Self: Sized,
{ fn main_binary() -> Result<Self, CargoError>; fn cargo_bin<S: AsRef<OsStr>>(name: S) -> Result<Self, CargoError>; fn cargo_example<S: AsRef<OsStr>>(name: S) -> Result<Self, CargoError>; }
Expand description

Create a Command for a bin in the Cargo project.

CommandCargoExt is an extension trait for [Command][Command] to easily launch a crate’s binaries.

See the cargo module documentation for caveats and workarounds.

Examples

use assert_cmd::prelude::*;

use std::process::Command;

let mut cmd = Command::main_binary()
    .unwrap();
let output = cmd.unwrap();

Required Methods§

Create a Command to run the crate’s main binary.

Note: only works if there one bin in the crate.

See the cargo module documentation for caveats and workarounds.

Examples
use assert_cmd::prelude::*;

use std::process::Command;

let mut cmd = Command::main_binary()
    .unwrap();
let output = cmd.unwrap();

Create a Command to run a specific binary of the current crate.

See the cargo module documentation for caveats and workarounds.

Examples
use assert_cmd::prelude::*;

use std::process::Command;

let mut cmd = Command::cargo_bin("bin_fixture")
    .unwrap();
let output = cmd.unwrap();

Create a Command to run a specific example of the current crate.

See the cargo module documentation for caveats and workarounds.

Examples
use assert_cmd::prelude::*;

use std::process::Command;

let mut cmd = Command::cargo_example("example_fixture")
    .unwrap();
let output = cmd.unwrap();

Implementations on Foreign Types§

Implementors§