cucumber-rust
An implementation of the Cucumber testing framework for Rust. Fully native, no external test runners or dependencies.
- Changelog
- Cucumber in Rust 0.7 – Beginner’s Tutorial by Florian Reinhard.
Usage
Create a directory called tests/
in your project root and create a test target of your choice. In this example we will name it cucumber.rs
.
Add this to your Cargo.toml
:
[]
= "0.1.42" # This is currently required to properly initialize the world in cucumber-rust
= "0.3.8" # You can use a different executor if you wish
[[]]
= "cucumber"
= false # Allows Cucumber to print output instead of libtest
[]
= { = "cucumber_rust", = "^0.8.0" }
Create a directory called features/
and put a feature file in it named something like example.feature
. It might look like:
Feature: Example feature
Scenario: An example scenario
Given I am trying out Cucumber
When I consider what I am doing
Then I am interested in ATDD
And we can implement rules with regex
And here's an example of implementing those steps using our tests/cucumber.rs
file:
use async_trait;
use ;
You can then run your Cucumber tests by running this command:
cargo test --test cucumber
Auto-wiring via macros
By enabling macros
feature in Cargo.toml
:
[]
= "0.1.42" # This is currently required to properly initialize the world in cucumber-rust
= "0.3.8" # You can use a different executor if you wish
[[]]
= "cucumber"
= false # Allows Cucumber to print output instead of libtest
[]
= { = "https://github.com/bbqsrc/cucumber-rust", = "main", = ["macros"] }
You could leverage some conveniences in organizing your tests code:
use ;
use async_trait;
use ;
async
async
Supporting crates
The full gamut of Cucumber's Gherkin language is implemented by the gherkin-rust project. Most features of the Gherkin language are parsed already and accessible via the relevant structs.
License
This project is licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.