-
Basically, my program is something like:
[package]
name = "my_web_server"
version = "0.0.1"
edition = "2018"
[dependencies]
clap = "2.33"
fn show() {
for argument in std::env::args_os() {
println!("{:?}", argument);
}
}
fn get_config() {
let _matches = clap::App::new("a").get_matches();
// blabla
}
fn main() {
show();
}
#[test]
fn test_a() {
show();
get_config();
// doing things based on the config, e.q. db connect...
assert!(true);
} I want to test it by $ cargo test test_a -- --nocapture
Compiling my_web_server v0.0.1 (/private/tmp/a)
Finished test [unoptimized + debuginfo] target(s) in 3.92s
Running target/debug/deps/my_web_server-722c15a8e468910d
running 1 test
"/private/tmp/a/target/debug/deps/my_web_server-722c15a8e468910d"
"test_a"
"--nocapture"
error: Found argument 'test_a' which wasn't expected, or isn't valid in this context
USAGE:
my_web_server-722c15a8e468910d
For more information try --help
error: test failed, to rerun pass '--bin my_web_server' I know I can manually parse arguments and pass to Is there an easy way to work with? |
Beta Was this translation helpful? Give feedback.
Answered by
pksunkara
Dec 2, 2020
Replies: 1 comment
-
You can try |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
pksunkara
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can try
assert_cmd
crate.