Skip to content
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

Merged
merged 3 commits into from
Jun 6, 2023
Merged

Add MaxAttempts trait to retry-able tests #85

merged 3 commits into from
Jun 6, 2023

Conversation

AArnott
Copy link
Owner

@AArnott AArnott commented Jun 6, 2023

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.

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);
Copy link
Contributor

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)

Copy link
Owner Author

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);
Copy link
Contributor

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

Copy link
Owner Author

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. 😉

@AArnott AArnott merged commit 14d88bb into main Jun 6, 2023
@AArnott AArnott deleted the retryCleanup branch June 6, 2023 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants