Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI redesign (#58, #134, #140) #144

Merged
merged 23 commits into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ All user visible changes to `cucumber` crate will be documented in this file. Th
- Replaced `#[given(step)]`, `#[when(step)]` and `#[then(step)]` function argument attributes with a single `#[step]`. ([#128])
- Made test callbacks first argument `&mut World` instead of `World`. ([#128])
- Made `#[step]` argument of step functions `Step` instead of `StepContext` again, while test callbacks still receive `StepContext` as a second parameter. ([#128])
- Deprecated `--nocapture` and `--debug` CLI options to be completely redesigned in `0.11` release. ([#137])
- Completely redesign and reworked CLI, making it composable and extendable. ([#144])
- [Hooks](https://cucumber.io/docs/cucumber/api/#hooks) now accept optional `&mut World` as their last parameter. ([#142])

### Added
Expand All @@ -35,6 +35,7 @@ All user visible changes to `cucumber` crate will be documented in this file. Th
[#137]: /../../pull/137
[#142]: /../../pull/142
[#143]: /../../pull/143
[#144]: /../../pull/144



Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ macros = ["cucumber-codegen", "inventory"]
[dependencies]
async-trait = "0.1.40"
atty = "0.2.14"
clap = { version = "=3.0.0-beta.5", features = ["derive"] }
console = "0.15"
derive_more = { version = "0.99.16", features = ["deref", "deref_mut", "display", "error", "from"], default_features = false }
either = "1.6"
Expand All @@ -44,12 +43,14 @@ linked-hash-map = "0.5.3"
once_cell = { version = "1.8", features = ["parking_lot"] }
regex = "1.5"
sealed = "0.3"
structopt = "0.3.25"

# "macros" feature dependencies
cucumber-codegen = { version = "0.10", path = "./codegen", optional = true }
inventory = { version = "0.1.10", optional = true }

[dev-dependencies]
humantime = "2.1"
tokio = { version = "1.12", features = ["macros", "rt-multi-thread", "time"] }

[[test]]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct World {
capacity: usize,
}

#[async_trait(? Send)]
#[async_trait(?Send)]
impl cucumber::World for World {
type Error = Infallible;

Expand Down
49 changes: 49 additions & 0 deletions book/src/Features.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,5 +382,54 @@ World::cucumber()



## CLI options

Library provides several options that can be passed to the command-line.

Use `--help` flag to print out all the available options:
```shell
cargo test --test <test-name> -- --help
```

Default output is:
```
cucumber 0.10.0
Run the tests, pet a dog!

USAGE:
cucumber [FLAGS] [OPTIONS]

FLAGS:
-h, --help Prints help information
-V, --version Prints version information
-v, --verbose Increased verbosity of an output: additionally outputs step's doc string (if present)

OPTIONS:
--color <auto|always|never> Coloring policy for a console output [default: auto]
-i, --input <glob> Glob pattern to look for feature files with. By default, looks for `*.feature`s
in the path configured tests runner
-c, --concurrency <int> Number of scenarios to run concurrently. If not specified, uses the value
configured in tests runner, or 64 by default
-n, --name <regex> Regex to filter scenarios by their name [aliases: scenario-name]
-t, --tags <tagexpr> Tag expression to filter scenarios by [aliases: scenario-tags]
```

Example with [tag expressions](https://cucumber.io/docs/cucumber/api#tag-expressions) for filtering `Scenario`s:
```shell
cargo test --test <test-name> -- --tags='@cat or @dog or @ferris'
```

> Note: CLI overrides any configurations set in the code.


### Customizing CLI options

CLI options are designed to be composable from the one provided by [`Parser::Cli`](https://docs.rs/cucumber/*/cucumber/trait.Parser.html#associatedtype.Cli), [`Runner::Cli`](https://docs.rs/cucumber/*/cucumber/trait.Runner.html#associatedtype.Cli) and [`Writer::Cli`](https://docs.rs/cucumber/*/cucumber/trait.Writer.html#associatedtype.Cli).

You may also extend CLI options with custom ones, if you have such a need for running your tests. See a [`cli::Opts` example](https://docs.rs/cucumber/*/cucumber/cli/struct.Opts.html#example) for more details.




[Cucumber]: https://cucumber.io
[Gherkin]: https://cucumber.io/docs/gherkin
1 change: 0 additions & 1 deletion codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ syn = { version = "1.0.74", features = ["derive", "extra-traits", "full"] }
[dev-dependencies]
async-trait = "0.1"
cucumber = { path = "..", features = ["macros"] }
futures = "0.3"
tokio = { version = "1.12", features = ["macros", "rt-multi-thread", "time"] }

[[test]]
Expand Down
8 changes: 4 additions & 4 deletions codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@
variant_size_differences
)]

use proc_macro::TokenStream;

mod attribute;
mod derive;

use proc_macro::TokenStream;

/// Helper macro for generating public shims for [`macro@given`], [`macro@when`]
/// and [`macro@then`] attributes.
macro_rules! step_attribute {
Expand Down Expand Up @@ -150,7 +150,7 @@ macro_rules! step_attribute {
/// - To use [`gherkin::Step`], name the argument as `step`,
/// **or** mark the argument with a `#[step]` attribute.
///
/// ```
/// ```rust
/// # use std::convert::Infallible;
/// #
/// # use async_trait::async_trait;
Expand All @@ -167,7 +167,7 @@ macro_rules! step_attribute {
/// # Ok(Self {})
/// # }
/// # }
///
/// #
/// #[given(regex = r"(\S+) is not (\S+)")]
/// fn test_step(
/// w: &mut MyWorld,
Expand Down
Loading