cucumber-rs / cucumber

Cucumber testing framework for Rust. Fully native, no external test runners or dependencies.
https://cucumber-rs.github.io/cucumber/main
Apache License 2.0
563 stars 69 forks source link

Running test in debug mode on Rust Rover #306

Open invent360 opened 11 months ago

invent360 commented 11 months ago

Sorry if this is an IDE issue but any clue of running test on debug mode ? Steps 1) click on "Debug Test execute"

Screenshot 2023-10-04 at 03 32 15 Screenshot 2023-10-04 at 03 32 04

start_app() basically establishes a db connection and starts a server on a different thread

async fn start_app() {
    let pool = PgPool::connect("postgres://<user>:<password>@localhost:<port>/db")
        .await
        .expect("Failed to connect to database");

    let server = run(pool.clone()).expect("Something terrible happened while starting server");

    let _ = tokio::spawn(server);
}

Result: DB connection is successfully established and server starts up but the following error is thrown

_Testing started at 03:26 ...
/Users/<local_path>/target/debug/deps/unit_test-28a3ee7b4f33429a execute --format=json --exact -Z unstable-options --show-output
error: unexpected argument 'execute' found

Usage: unit_test-28a3ee7b4f33429a [OPTIONS]

For more information, try '--help'.

Process finished with exit code 2_

Note: Test runs well without errors when executed on command lines as follows cargo test -p nubia --test unit_test

tyranron commented 11 months ago

@invent360 I guess Unit::run() by default tries to parse CLI args, and execute --format=json --exact -Z unstable-options --show-output is not something expected by it. You should specify cli::Args manually in this case, because you're running tests harness = false. See this chapter of the Book, .with_cli() docs and .with_default_cli() docs.

tyranron commented 11 months ago

Also, similar question was discussed here: https://github.com/cucumber-rs/cucumber/discussions/294