Skip to content

Conversation

@manfred-brands
Copy link
Member

Fixes #1098

Copy link
Contributor

Copilot AI left a 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 RetryAttribute usage
  • Updates the retry attribute documentation to include references to these examples
  • Revises documentation text to clarify exception handling behavior with the RetryExceptions property

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.

@manfred-brands manfred-brands force-pushed the RetryException branch 2 times, most recently from a8bcfa3 to ce83ebb Compare November 24, 2025 06:49
Copy link
Contributor

Copilot AI left a 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)])]
Copy link

Copilot AI Nov 24, 2025

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.

Suggested change
[Retry(5, RetryExceptions = [typeof(OperationCanceledException)])]
[Retry(3, RetryExceptions = [typeof(OperationCanceledException)])]

Copilot uses AI. Check for mistakes.
Copy link
Member

@OsirisTerje OsirisTerje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@SeanKilleen SeanKilleen merged commit d7f76c4 into master Nov 25, 2025
7 checks passed
@SeanKilleen SeanKilleen deleted the RetryException branch November 25, 2025 00:42
github-actions bot pushed a commit that referenced this pull request Nov 25, 2025
* 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
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.

Document RetryAttribute's ability to retry on exceptions

5 participants