- Notifications
You must be signed in to change notification settings - Fork78
Cucumber testing framework for Rust. Fully native, no external test runners or dependencies.
License
Apache-2.0, Unknown licenses found
Licenses found
cucumber-rs/cucumber
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
An implementation of theCucumber testing framework for Rust. Fully native, no external test runners or dependencies.
Describe testing scenarios in.feature
files:
Feature: Eating too much cucumbers may not be good for youScenario: Eating a few isn't a problemGivenAlice is hungryWhenshe eats 3 cucumbersThenshe is full
ImplementWorld
trait and describe steps:
use std::time::Duration;use cucumber::{Worldas _, given, then, when};use tokio::time::sleep;#[derive(Debug,Default, cucumber::World)]structWorld{user:Option<String>,capacity:usize,}#[given(expr ="{word} is hungry")]// Cucumber Expressionasyncfnsomeone_is_hungry(w:&mutWorld,user:String){sleep(Duration::from_secs(2)).await; w.user =Some(user);}#[when(regex =r"^(?:he|she|they) eats? (\d+) cucumbers?$")]asyncfneat_cucumbers(w:&mutWorld,count:usize){sleep(Duration::from_secs(2)).await; w.capacity += count;assert!(w.capacity <4,"{} exploded!", w.user.as_ref().unwrap());}#[then("she is full")]asyncfnis_full(w:&mutWorld){sleep(Duration::from_secs(2)).await;assert_eq!(w.capacity,3,"{} isn't full!", w.user.as_ref().unwrap());}#[tokio::main]asyncfnmain(){World::run("tests/features/readme").await;}
Add test toCargo.toml
:
[[test]]name ="readme"harness =false# allows Cucumber to print output instead of libtest
For more examples check out the Book (current |edge).
macros
(default): Enables step attributes and auto-wiring.timestamps
: Enables timestamps collecting for allCucumber events.output-json
(impliestimestamps
): Enables support for outputting inCucumber JSON format.output-junit
(impliestimestamps
): Enables support for outputtingJUnit XML report.libtest
(impliestimestamps
): Enables compatibility withRustlibtest
's JSON output format. Useful forIntelliJ Rust plugin integration.tracing
: Enablesintegration withtracing
crate.
The full gamut of Cucumber'sGherkin language is implemented by thegherkin
crate. Most features of theGherkin language are parsed already and accessible via the relevant structs.
Scenario Outline
is treated the same asOutline
orExample
in the parser (gherkin/#19).
This project is licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE orhttp://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT orhttp://opensource.org/licenses/MIT)
at your option.
About
Cucumber testing framework for Rust. Fully native, no external test runners or dependencies.
Topics
Resources
License
Apache-2.0, Unknown licenses found
Licenses found
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.