-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
parameterizing fixtures #93
Comments
I already thought about that when I started to think on rstest. This's a pytest's feature that I really like and I would like implement in rstest too.... but rust is a static language and any test should be build at compile time and not run time. But I didn't found any way to implement it preserving the rule 1 case => 1 test case without using any kind of custom test runner. I can try to give another try to it... Maybe in a lot of cases we can work around on it by something like described in #80 |
There's another option which would be nearly as useful. In every case I've encountered so far, the list of parameters is constant. So if there were some way to express it as a macro, then I could reuse it. Something a little like this, perhaps: macro_rules! myparams {
() => [1, 2, 3];
}
#[rstest inputs => myparams!()]
fn test_a(inputs: i32) {
...
}
#[rstest inputs => myparams!()]
fn test_b(inputs: i32) {
...
} |
I already tried something like this but when Rust compiler call procedural macro expansion with just the follow syntax tree and standard macro expansion come later.... |
I was afraid you'd say something like that. I guess it'll take a custom test runner then. |
I didn't take in account to build a custom test runner because
I think that Rust's guy have did a very good think to make tests simple and very well integrated: my attempt is to preserve this simple approach. Anyway I would like to write something to reuse test case set. That is a really need to have feature. |
Yes I saw it. But for now I'm sticking with the galvanic-test crate. It provides a nicer syntax for parameterizing tests. The downside is that parameterizations aren't independent. They all run as a single test case. |
I think I can close this issue: I think that rstest_reuse fit all cases explained in this ticket. Ok, it don't provide a parametrized fixture but |
With rstest, I can parameterize a test case using
#[rstest(foo => [...])]
or#[rstest(foo, case(...), ...)]
syntax. But I don't see any way to parameterize a fixture. What I would like to do would be to define a fixture that can return multiple values, and use that to parameterize several test cases, like this:I would then expect to see six separate test cases get run, like
Would such a thing be possible?
The text was updated successfully, but these errors were encountered: