cucumber-thirtyfour-worlder

Crates.iocucumber-thirtyfour-worlder
lib.rscucumber-thirtyfour-worlder
version0.1.5
created_at2025-05-24 11:06:11.803137+00
updated_at2025-05-27 11:12:48.323911+00
descriptionWorld builder with sensible defaults for cucumber integration with thirtyfour.
homepage
repository
max_upload_size
id1687310
size43,102
Álvaro Mondéjar Rubio (mondeja)

documentation

README

cucumber-thirtyfour-worlder

Crates.io License Tests macro docs.rs reference docs.rs Crates.io downloads

Do you need to reuse a bunch of logic between different projects testing apps with cucumber-rs and thirtyfour? This crate is for you.

Provides a cucumber::World builder that can be used to create an AppWorld for thirtyfour tests, allowing to inject environment variables to parametrize them.

  • BROWSER: browser to use. Supported are firefox, chrome, and edge.
  • HEADLESS: by default, tests are executed in headless mode. Set this to false to run them in a visible browser.
  • WINDOW_SIZE: size of the browser window. The default is 1920x1080.
  • HOST_URL: base URL of the application under test. The default is http://localhost:8080.
  • DRIVER_URL: the URL of the WebDriver server. The default is http://localhost:4444.

Usage

Create a crate and add the following dependencies to your Cargo.toml.

[dependencies]
cucumber = "0.21"
thirtyfour = "0.35"
cucumber-thirtyfour-worlder = "0.1"

Inside, create your AppWorld struct and pass it the #[worlder] attribute.

use cucumber_thirtyfour_worlder::worlder;

#[worlder]
pub struct AppWorld;

See the reference of the created world here.

Then, create a crate for tests and run the world as you would do with cucumber::World directly.

// tests/desktop.rs
use your_crate::AppWorld;
use cucumber::World;

#[tokio::main]
async fn main() {
    AppWorld::cucumber()
        .fail_on_skipped()
        .run_and_exit("./features/desktop")
        .await
}

Start a webdriver server before running the tests.

chromedriver --port=4444
# or `geckodriver --port=4444` (for Firefox)
# or `msedgedriver --port=4444` (for MsEdge)

And run your tests passing a browser in the BROWSER environment variable.

BROWSER=chrome cargo test --package your-crate --test desktop -- --fail-fast

Where desktop is the name of your test file and your-crate is the name of the crate that contains the AppWorld struct.

Known issues

Additional configuration for cargo-machete

The cargo-machete tool don't know that you're not using cucumber and thirtyfour, so it could complain about missing dependencies. To fix this, add the following to your Cargo.toml.

[package.metadata.cargo-machete]
ignored = ["thirtyfour", "cucumber"]
Commit count: 0

cargo fmt