-
Notifications
You must be signed in to change notification settings - Fork 161
Add Retry and Retry with RetryExceptions examples #1099
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
Conversation
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.
Pull request overview
This PR adds code examples to demonstrate the usage of NUnit's RetryAttribute, specifically showing basic retry functionality and retry with specific exception types. The changes address issue #1098 by providing practical examples in the documentation.
- Adds a new code snippet file with two example test fixtures demonstrating
RetryAttributeusage - Updates the retry attribute documentation to include references to these examples
- Revises documentation text to clarify exception handling behavior with the
RetryExceptionsproperty
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| docs/snippets/Snippets.NUnit/RetryAttributeExamples.cs | New file containing two test fixtures: one demonstrating basic retry behavior and another showing retry with specific exceptions |
| docs/articles/nunit/writing-tests/attributes/retry.md | Updated to reference the new code examples and clarify exception retry behavior |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
a8bcfa3 to
ce83ebb
Compare
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.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| [Test] | ||
| [Retry(5, RetryExceptions = [typeof(OperationCanceledException)])] |
Copilot
AI
Nov 24, 2025
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.
[nitpick] The retry count of 5 seems excessive for a cancellation timeout scenario. Since the delay decreases by 1000ms per attempt and starts at 2500ms, only 2-3 retries are needed (2500ms → 1500ms → 500ms). Consider reducing to [Retry(3)] for a more realistic example.
| [Retry(5, RetryExceptions = [typeof(OperationCanceledException)])] | |
| [Retry(3, RetryExceptions = [typeof(OperationCanceledException)])] |
ce83ebb to
45ca946
Compare
45ca946 to
e913cf1
Compare
OsirisTerje
left a comment
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.
lgtm
* Add Retry and Retry with RetryExceptions examples * Update to latest nunit alpha package * Add a note that RetryExceptions is only available from NUnit 4.5.0 d7f76c4
Fixes #1098