Hiya! I've appeared here since assert_cli is deprecated, and tried swapping over from assert_cli 0.6 to assert_cmd 0.9
My really short experience (so far) has been something like this:
- Let's swap over the
assert_cli to assert_cmd in the imports
- Okay, so
Commands from std are extended by traits, cool!
- How do I get environment stuff in? It's not mentioned in these docs, let me check
std, okay it's there.
- How do I write things to
stdin? Searched and found CommandStdInExt.
- What's
.with_stdin().buffer("..").unwrap()? Why can't I call .buffer("") twice? Oh we're no longer the builder.
- Is this
unwrap() the assertion? No wait it just gives me the StdinCommand
- How do I assert? Searched and found
OutputAssertExt.
- The example on the output extension page is a trivial example. How did it get an
Output again? Oh it's a std type.
- Okay I had a
StdinCommand, or was it a Result<StdinCommand>.
- Oh man. I have successfully been confused.
- Let's open many tabs.
- No wait let's open an issue.
There's a lot of jumping around trying to figure out "what type do I have, is it a Builder, a Result, a normal type by extended by some trait". Also, the Result's errors aren't all the same type (and aren't convertible), so I can't easily go main_binary()? and then later on .output()?.assert().success().
I think we need an example on the first page (and perhaps README.md) that does a complete test. The piecewise explanations are good on their own, but it's hard to tie them together. That is, literally every method call gives me a different type:
extern crate assert_cmd;
use assert_cmd::{cargo::CargoError, prelude::*};
use std::process::Command;
#[test]
fn integration_test() -> Result<(), CargoError> {
Command::main_binary()?
.env("APP_VAR", "value") // https://doc.rust-lang.org/std/process/struct.Command.html#method.env
.with_stdin() // https://docs.rs/assert_cmd/0.9.1/assert_cmd/trait.CommandStdInExt.html
.buffer("exit\n") // https://docs.rs/assert_cmd/0.9.1/assert_cmd/struct.StdInCommandBuilder.html#method.buffer
.output() // https://docs.rs/assert_cmd/0.9.1/assert_cmd/struct.StdInCommand.html#method.output
.unwrap() // Gives you back the `Output`
.assert() // https://docs.rs/assert_cmd/0.9.1/assert_cmd/assert/trait.OutputAssertExt.html#tymethod.assert
.success(); // https://docs.rs/assert_cmd/0.9.1/assert_cmd/assert/struct.Assert.html#method.success
Ok(())
}
FWIW I was trying to port this test over:
let environment =
assert_cli::Environment::inherit().insert("APP_DIR", env!("CARGO_MANIFEST_DIR"));
assert_cli::Assert::main_binary()
.with_env(&environment)
.stdin("exit\n")
.unwrap();
Off topic, CONTRIBUTING.md looks like it might have been copied from something called stager.
Hiya! I've appeared here since
assert_cliis deprecated, and tried swapping over fromassert_cli 0.6toassert_cmd 0.9My really short experience (so far) has been something like this:
assert_clitoassert_cmdin the importsCommands fromstdare extended by traits, cool!std, okay it's there.stdin? Searched and foundCommandStdInExt..with_stdin().buffer("..").unwrap()? Why can't I call.buffer("")twice? Oh we're no longer the builder.unwrap()the assertion? No wait it just gives me theStdinCommandOutputAssertExt.Outputagain? Oh it's astdtype.StdinCommand, or was it aResult<StdinCommand>.There's a lot of jumping around trying to figure out "what type do I have, is it a
Builder, aResult, a normal type by extended by some trait". Also, theResult's errors aren't all the same type (and aren't convertible), so I can't easily gomain_binary()?and then later on.output()?.assert().success().I think we need an example on the first page (and perhaps
README.md) that does a complete test. The piecewise explanations are good on their own, but it's hard to tie them together. That is, literally every method call gives me a different type:FWIW I was trying to port this test over:
Off topic, CONTRIBUTING.md looks like it might have been copied from something called
stager.