Expand description
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 arefirefox,chrome, andedge.HEADLESS: by default, tests are executed in headless mode. Set this tofalseto run them in a visible browser.WINDOW_SIZE: size of the browser window. The default is1920x1080.HOST_URL: base URL of the application under test. The default ishttp://localhost:8080.DRIVER_URL: the URL of theWebDriverserver. The default ishttp://localhost:4444.DOWNLOADS_DIR: directory where files downloaded by the browser. The default is a random temporary directory.
§Usage
Create a crate and add the following dependencies to your Cargo.toml.
[dependencies]
cucumber = "0.21"
thirtyfour = "0.35"
cucumber-thirtyfour-worlder = "0.2"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-fastWhere 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"]Attribute Macros§
- worlder
- Attribute macro to build
cucumber::Worldstruct for the app to test.