Is there a recommended way to tag tests and run them by specifying the tag(s)?
For example:
#[test(tag = "fast")]
fn test_xxx() {
...
}
And then run the tests with a command like: cargo test --tag fast?
I found multiple approaches to achieve this goal, but none of them seem particularly idiomatic to me. Is there an idiomatic or recommended way to do this in Rust? Does any up-to-date and active test framework in Rust already support this functionality? Or is there any plan for Rust to add features like this to its standard library and toolchain?
Thanks. Today I did some research and found these two ways. They are workable, but they are the ways I think not idiomatic. A tag is like some extra info or group name, and add it to every test function name is not the semantics I want. I personally also don't like the feature way. I prefer some code looks more straightforward. If no standard and simple way, I'd like to use a build script, and pass the cargo --config test_tag=fast through environment variable to a procedural macro and make the code like:
Cargo is stuck having a primitive internal interface for tests, and due to that interface and backward compatibility concerns, any test improvements are taking a lot of time, and get blocked on many design and implementation issues. It has been like that for 7 years now:
Cargo as a project is understaffed and is struggling to even triage outside contributions, so don't hold your breath for new test features.