Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Cucumber testing framework for Rust. Fully native, no external test runners or dependencies.

License

Apache-2.0, Unknown licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
Unknown
LICENSE-MIT
NotificationsYou must be signed in to change notification settings

cucumber-rs/cucumber

Repository files navigation

crates.ioRust 1.87+Unsafe Forbidden
CIRust docs

An implementation of theCucumber testing framework for Rust. Fully native, no external test runners or dependencies.

Usage

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).

Cargo features

Supporting crates

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.

Known issues

  • Scenario Outline is treated the same asOutline orExample in the parser (gherkin/#19).

License

This project is licensed under either of

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

Apache-2.0
LICENSE-APACHE
Unknown
LICENSE-MIT

Security policy

Stars

Watchers

Forks

Contributors32


[8]ページ先頭

©2009-2025 Movatter.jp