Skip to content


Switch branches/tags

Cucumber testing framework for Rust Documentation CI Rust 1.62+ Unsafe Forbidden

An implementation of the Cucumber 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 you
  Scenario: Eating a few isn't a problem
    Given Alice is hungry
    When she eats 3 cucumbers
    Then she is full

Implement World trait and describe steps:

use std::time::Duration;

use cucumber::{given, then, when, World as _};
use tokio::time::sleep;

#[derive(cucumber::World, Debug, Default)]
struct World {
    user: Option<String>,
    capacity: usize,

#[given(expr = "{word} is hungry")] // Cucumber Expression
async fn someone_is_hungry(w: &mut World, user: String) {
    w.user = Some(user);

#[when(regex = r"^(?:he|she|they) eats? (\d+) cucumbers?$")]
async fn eat_cucumbers(w: &mut World, count: usize) {

    w.capacity += count;
    assert!(w.capacity < 4, "{} exploded!", w.user.as_ref().unwrap());

#[then("she is full")]
async fn is_full(w: &mut World) {

    assert_eq!(w.capacity, 3, "{} isn't full!", w.user.as_ref().unwrap());

async fn main() {

Add test to Cargo.toml:

name = "readme"
harness = false  # allows Cucumber to print output instead of libtest

For more examples check out the Book (current | edge).

Cargo features

Supporting crates

The full gamut of Cucumber's Gherkin language is implemented by the gherkin crate. Most features of the Gherkin language are parsed already and accessible via the relevant structs.

Known issues

  • Scenario Outline is treated the same as Outline or Example in the parser (gherkin/#19).


This project is licensed under either of

at your option.