3 releases (breaking)

0.4.0 Jan 26, 2022
0.3.0 Nov 26, 2019
0.2.0 Oct 6, 2019
0.1.0 Oct 5, 2019

#386 in Testing

Download history 2392/week @ 2024-08-03 3205/week @ 2024-08-10 2498/week @ 2024-08-17 2468/week @ 2024-08-24 2665/week @ 2024-08-31 2225/week @ 2024-09-07 2111/week @ 2024-09-14 2844/week @ 2024-09-21 2560/week @ 2024-09-28 3543/week @ 2024-10-05 4027/week @ 2024-10-12 3578/week @ 2024-10-19 2867/week @ 2024-10-26 3669/week @ 2024-11-02 4226/week @ 2024-11-09 3458/week @ 2024-11-16

14,903 downloads per month
Used in 12 crates

MIT/Apache

8KB

test_bin

A crate for getting the crate binary in an integration test.

If you are writing a command-line interface app then it is useful to write an integration test that uses the binary. You most likely want to launch the binary and inspect the output. This module lets you get the binary so it can be tested.

Example

Here is the basic usage:

let output = test_bin::get_test_bin("my_cli_app")
    .output()
    .expect("Failed to start my_binary");
assert_eq!(
    String::from_utf8_lossy(&output.stdout),
    "Output from my CLI app!\n"
);

Acknowledgements

The cargo and ripgrep crates were used as inspiration. They both test their binaries using a similar approach. The cargo crate's documentation and license was used as a starting point.

Contributing

See CONTRIBUTING.md.

License

The test_bin crate is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT for details.

No runtime deps