#test #bin #testing-library #command-line #binary #testing #integration-tests

dev bin+lib test_bin

A crate for getting the crate binary in an integration test

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

#742 in Filesystem

Download history 936/week @ 2023-10-22 723/week @ 2023-10-29 637/week @ 2023-11-05 542/week @ 2023-11-12 588/week @ 2023-11-19 676/week @ 2023-11-26 567/week @ 2023-12-03 759/week @ 2023-12-10 447/week @ 2023-12-17 516/week @ 2023-12-24 808/week @ 2023-12-31 807/week @ 2024-01-07 634/week @ 2024-01-14 1687/week @ 2024-01-21 1288/week @ 2024-01-28 955/week @ 2024-02-04

4,733 downloads per month
Used in 8 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