-
Notifications
You must be signed in to change notification settings - Fork 32
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
Add MaxAttempts trait to retry-able tests #85
Conversation
Assert.Fail("This test should not have run a second time because the first run was successful."); | ||
} | ||
} | ||
public void AutomaticRetryNotNeeded() => MaxAttemptsHelper.ThrowUnlessAttemptNumber(this.GetType(), MethodBase.GetCurrentMethod()!.Name, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💭 With CallerFilePath
and CallerLineNumber
, you could probably get this down to:
MaxAttemptsHelper.ThrowUnlessAttemptNumber(1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for theories. But I agree we could remove the test class argument. File path would work until we have derived test classes that inherit tests. But this repo doesn't and isn't likely to have those.
I think I'll leave it as-is though for now.
Assert.Fail("This test should not have run a second time because the first run was successful."); | ||
} | ||
} | ||
public void AutomaticRetryNotNeeded(int arg) => MaxAttemptsHelper.ThrowUnlessAttemptNumber(this.GetType(), $"{MethodBase.GetCurrentMethod()!.Name}_{arg}", 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 The inclusion of arg
here makes it more difficult to simplify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a way to avoid it. You added it originally. 😉
The added
MaxAttempts
trait makes tests groupable and filterable based on their retry attribution.I also clean up some unnecessary casts and simplify the retry tests.