You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#[derive(Debug,PartialEq)]enumFruit{Apple,Banana,Orange,}#[rstest]#[case(Fruit::Apple)]#[case(Fruit::Banana)]fntest_enum_values(#[case]fruit:Fruit){// Test logic hereassert_ne!(fruit,Fruit::Orange);}
Is there a nice way of simply giving the enum type only so that all variants are tested (or that none of the variants are forgotten)? The logic above won't give an indication about that.
Or otherwise, if it's not easily doable, it could be a feature request.
The text was updated successfully, but these errors were encountered:
No, I should say sadly that there isn't any way to do it today and is not simple to implement it.
rstest procedural macro cannot know the enum definition because is processed on the early stage immediately after the parsing stage and just the AST of the item that's processed is know (in this case the function): the type resolution is a later stage.
Anyway we can think a sub-optimal convoluted approach like the one used in rstest_reuse where an enum annotation
generate a macro definition that we can use to generate a #[value] annotation in the signature: example
The sad thing here is that (maybe) I cannot move it the argument annotation but I should annotate that rstest function to be sure to process it before the rstest one.
Typically you would do something like:
Is there a nice way of simply giving the enum type only so that all variants are tested (or that none of the variants are forgotten)? The logic above won't give an indication about that.
Or otherwise, if it's not easily doable, it could be a feature request.
The text was updated successfully, but these errors were encountered: