Add mocked resilience tests exercising the Polly pipeline#393
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #393 +/- ##
========================================
Coverage 46.20% 46.20%
========================================
Files 13 13
Lines 1160 1160
Branches 107 107
========================================
Hits 536 536
Misses 593 593
Partials 31 31 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds deterministic, offline xUnit tests to exercise the HttpClientFactory resilience pipeline (Polly retry/circuit-breaker) against scripted HTTP outcomes, and updates test analyzer settings to avoid unsatisfiable async rules in xUnit tests.
Changes:
- Add
HttpClientFactoryResilienceTeststhat validate transient vs non-transient status handling and timeout-vs-caller-cancellation behavior through the real resilience handler. - Introduce a test-only
StubHttpMessageHandlerto provide scripted responses/exceptions and track attempt counts. - Disable CA2007 in
UtilitiesTeststo avoid conflict with xUnit’s ConfigureAwait guidance in test code.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| UtilitiesTests/HttpClientFactoryResilienceTests.cs | Adds new deterministic tests and a stub transport to validate retry/transient classification in the resilience pipeline. |
| UtilitiesTests/.editorconfig | Disables CA2007 for the test project to avoid conflict with xUnit analyzer guidance. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds deterministic, network-free tests that actually exercise the
HttpClientFactoryresilience pipeline (previously the factory tests only constructed clients). A stubHttpMessageHandleris swapped in as the resilience handler's inner transport, so the real Polly retry/circuit-breaker pipeline runs against scripted outcomes offline.Covers the transient-classification logic in
IsTransientFailure:TimeoutException): retried - validates that request timeouts are treated as transient.OperationCanceledException): not retried.These deterministically confirm the timeout-vs-cancellation behavior without relying on CI network availability.
Notes
CA2007suppression toUtilitiesTests/.editorconfig: xUnit forbidsConfigureAwaitin test methods (xUnit1030), so CA2007 is unsatisfiable in async test helpers (standard practice for test projects).Verification
dotnet build- 0 warnings / 0 errors.dotnet test- 149 passed (+4).dotnet format style --verify-no-changesclean.🤖 Generated with Claude Code