-
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
Use just [rstest]
to generate test.
#42
Comments
Should work... maybe I can just remove Ok, I'll do some tests. If I don't find any problem I'll deprecate |
[rstest]
to generate test.
By
For instance in the same test you can have a parameter from list and other 2 from cases: in this case will run all cases for each value in list. |
I don't think This following snippet #[rstest(
params(foo, bar),
matrix(
foo => [0, 1, 2],
bar => ['a', 'b'],
),
case(8, 'f'),
)]
fn mytest(foo: i32, bar: char) {} should be equivalent to #[rstest_parametrize(
foo, bar,
case(0, 'a'),
case(1, 'a'),
case(2, 'a'),
case(0, 'b'),
case(1, 'b'),
case(2, 'b'),
case(8, 'f'),
)]
fn mytest(foo: i32, bar: char) {} I not sure if this syntax is good enough. |
Ok, I'll think about this even if my idea is that in test writing you should remove all boilerplate that you can even if the syntax become less explicit. |
Rustfmt has a problem with current #[rstest_parametrize(
foo, bar, baz,
case(0, 'a', 'A'),
case(1, 'b', 'B'),
)
fn mytest (foo: u32, baz: char, baz: char) {} into this #[rstest_parametrize(
foo,
bar,
baz,
case(0, 'a', 'A'),
case(1, 'b', 'B'),
)
fn mytest (foo: u32, baz: char, baz: char) {} This is why I think |
Hi @KSXGitHub, I don't think that how on my machine use #[rstest_parametrize(foo, bar, baz, case(0, 'a', 'A'), case(1, 'b', 'B'))]
fn mytest(foo: u32, bar: char, baz: char) {} Anyway what we are doing here is to build a new DSL and we cannot write DSL according to I took a look to #[rustfmt::skip]
#[rstest_parametrize(
foo, bar, baz,
case(0, 'a', 'A'),
case(1, 'b', 'B'),
)]
fn mytest (foo: u32, bar: char, baz: char) {} Or use a small comment to do the trick #[rstest_parametrize( // This prevent formatting
foo, bar, baz,
case(0, 'a', 'A'),
case(1, 'b', 'B'),
)]
fn mytest (foo: u32, bar: char, baz: char) {} |
Maybe by use rust-lang/rust#60406 we can improve the syntax a lot by move argument related data near the argument instead try to express it external attribute. |
Just for the record: rust-lang/rustfmt#3665 will introduce |
I'm staring to work on it (moved on 0.5 release) TODO:
|
Implementation and tests are done. Docs moved in other ticket : see #67 |
My macro knowledge is pretty poor so please excuse my ignorance, but I think it'd be conceptually and syntactically to use have
[rstest]
which may also be optionally parametrized. What do you think?The text was updated successfully, but these errors were encountered: