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

`cargo test` does not detect main functions #312

Closed bachrc closed 9 months ago

bachrc commented 9 months ago

In the official documentation, the recommended way to add a test is to make a example.rs test, and to do a main() function with either futures or a #[tokio::main] to contains the World::run.

Though, this method is not detected when doing cargo test --test example. Because it only detects methods annotated with #[test], examples everywhere in the documentation does not work, unless the method is annotated with #[tokio::test]

tyranron commented 9 months ago

@bachrc it always worked for us. Didn't you miss

[[test]]
name = "example"
harness = false

in your Cargo.toml?

bachrc commented 9 months ago

Yup! I have a simple workspace which contains the integration_tests member.

This crate has this [[test]] section. So when I launch cargo test -p integration_tests --test example, it doesn't detect any test in my integration_tests/tests/example.rs. Unless I annotate with #[tokio::test]

bachrc commented 9 months ago

I am sorry for making you lose some time, this was a shitty mistake on my end...

I wrote [[tests]] in my Cargo.toml file, and not [[test]]... works way better now. Thank you for your wonderful library, please have a nice day