-
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
#[ignore]
at the top only applies to the first case
#210
Comments
You're expecting wrong 😄 Every case collect the attributes that preceding it and all attributes between the last case and function definition is applied to the function itself and so to all tests. |
I agree that as documented it's technically correct, but I do think that this: #[ignore]
#[rstest]
#[case::is_ignored()]
#[case::isnt_ignored()]
fn only_ignores_first() {} is not obviously the same as this: #[rstest]
#[ignore]
#[case::is_ignored()]
#[case::isnt_ignored()]
fn only_ignores_first() {} In the second example, it's very intuitive for the attribute to only apply to the first case. But in the first example, it doesn't look like it should be applied to a specific case at all. When I see an attribute outside the "scope" of the rstest macro like that, I assume it'll be applied broadly across all cases. Unlike in the first example, there isn't really a clear visual connection to the first case. Here's another way to frame my perspective. Let's say I'm writing a test with a few cases, and I want to ignore the first case. I am almost certainly going to stick the ignore directly above the case, rather than above the Maybe this doesn't warrant a change in behaviour, especially since that could break existing code. But I think it warrants a warning, since there's an easy way to rewrite it to be more clear, and it'll catch cases where people did this by accident. |
Ok, you are partially right. Is true that the attributes before To be coherent I should leave them on the top of the expanded code and that will generate an error (you cannot apply Anyway I'll add an error message if I found some attributes before the THX for reporting it. |
Ok, I've come back on this and unfortunately is quite impossible to fix it. There is no way to understand if some attribute is before or not to #[ignore]
#[rstest]
#[case::is_ignored()]
#[case::isnt_ignored()]
fn only_ignores_first() {} #[rstest]
#[ignore]
#[case::is_ignored()]
#[case::isnt_ignored()]
fn only_ignores_first() {} The only difference from the first and the second case is the span associated to I've tried also to leverage on attributes 😢 |
Given the following code:
I expect that all test cases will be ignored. Instead,
only_ignores_first
only sees the first test case ignored:rstest version is 0.18.2
The text was updated successfully, but these errors were encountered: