From e28f2715f93aa14bbf7109012eb5efe3aba73a2c Mon Sep 17 00:00:00 2001 From: martincostello Date: Sat, 23 Aug 2025 14:12:12 +0100 Subject: [PATCH 1/6] Update to xunit v3 Update to xunit v3. Resolves #2439. --- Directory.Packages.props | 3 ++- eng/Test.targets | 2 +- src/Snippets/Snippets.csproj | 2 +- .../Hedging/HedgingResilienceStrategyTests.cs | 1 - test/Polly.Core.Tests/Polly.Core.Tests.csproj | 1 + test/Polly.Core.Tests/ResiliencePipelineTests.cs | 2 +- .../Utils/Pipeline/PipelineComponentFactoryTests.cs | 10 +++++----- .../Polly.Extensions.Tests.csproj | 1 + .../Polly.RateLimiting.Tests.csproj | 1 + .../Helpers/Bulkhead/AnnotatedOutputHelper.cs | 2 ++ .../Helpers/Bulkhead/SilentOutputHelper.cs | 12 ++++++++++++ test/Polly.Specs/Polly.Specs.csproj | 2 +- test/Polly.Testing.Tests/Polly.Testing.Tests.csproj | 1 + test/Shared/TestCancellation.cs | 4 +++- 14 files changed, 32 insertions(+), 12 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 90d4c831dd6..0ee0615a61d 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -38,8 +38,9 @@ - + + diff --git a/eng/Test.targets b/eng/Test.targets index 4058f40c299..8a7839a611d 100644 --- a/eng/Test.targets +++ b/eng/Test.targets @@ -18,8 +18,8 @@ - + diff --git a/src/Snippets/Snippets.csproj b/src/Snippets/Snippets.csproj index 6105b0c4930..2d5cd695c9e 100644 --- a/src/Snippets/Snippets.csproj +++ b/src/Snippets/Snippets.csproj @@ -30,7 +30,7 @@ - + diff --git a/test/Polly.Core.Tests/Hedging/HedgingResilienceStrategyTests.cs b/test/Polly.Core.Tests/Hedging/HedgingResilienceStrategyTests.cs index f196b730cce..2c6b1aab850 100644 --- a/test/Polly.Core.Tests/Hedging/HedgingResilienceStrategyTests.cs +++ b/test/Polly.Core.Tests/Hedging/HedgingResilienceStrategyTests.cs @@ -3,7 +3,6 @@ using Polly.Hedging.Utils; using Polly.Telemetry; using Polly.Testing; -using Xunit.Abstractions; namespace Polly.Core.Tests.Hedging; diff --git a/test/Polly.Core.Tests/Polly.Core.Tests.csproj b/test/Polly.Core.Tests/Polly.Core.Tests.csproj index fed35451ec5..334ad8931db 100644 --- a/test/Polly.Core.Tests/Polly.Core.Tests.csproj +++ b/test/Polly.Core.Tests/Polly.Core.Tests.csproj @@ -7,6 +7,7 @@ enable 100 $(NoWarn);S6966 + Exe [Polly.Core]* true diff --git a/test/Polly.Core.Tests/ResiliencePipelineTests.cs b/test/Polly.Core.Tests/ResiliencePipelineTests.cs index c47604b7908..614c3f2ba14 100644 --- a/test/Polly.Core.Tests/ResiliencePipelineTests.cs +++ b/test/Polly.Core.Tests/ResiliencePipelineTests.cs @@ -11,7 +11,7 @@ public partial class ResiliencePipelineTests #pragma warning disable IDE0028 public static TheoryData ResilienceContextPools = new() { - null, + null as ResilienceContextPool, ResilienceContextPool.Shared, }; #pragma warning restore IDE0028 diff --git a/test/Polly.Core.Tests/Utils/Pipeline/PipelineComponentFactoryTests.cs b/test/Polly.Core.Tests/Utils/Pipeline/PipelineComponentFactoryTests.cs index 40eb7f2b26d..d708fce04f9 100644 --- a/test/Polly.Core.Tests/Utils/Pipeline/PipelineComponentFactoryTests.cs +++ b/test/Polly.Core.Tests/Utils/Pipeline/PipelineComponentFactoryTests.cs @@ -8,17 +8,17 @@ public class PipelineComponentFactoryTests #pragma warning disable IDE0028 public static TheoryData> EmptyCallbacks = new() { - Array.Empty(), + Array.Empty() as IEnumerable, Enumerable.Empty(), - new List(), - new EmptyActionEnumerable(), // Explicitly does not provide TryGetNonEnumeratedCount() + new List() as IEnumerable, + new EmptyActionEnumerable() as IEnumerable, // Explicitly does not provide TryGetNonEnumeratedCount() }; public static TheoryData> NonEmptyCallbacks = new() { - new[] { () => { } }, + new[] { () => { } } as IEnumerable, Enumerable.TakeWhile(Enumerable.Repeat(() => { }, 50), (_, i) => i < 1), // Defeat optimisation for TryGetNonEnumeratedCount() - new List { () => { } }, + new List { () => { } } as IEnumerable, }; #pragma warning restore IDE0028 diff --git a/test/Polly.Extensions.Tests/Polly.Extensions.Tests.csproj b/test/Polly.Extensions.Tests/Polly.Extensions.Tests.csproj index de94ed52283..c65e962b7dc 100644 --- a/test/Polly.Extensions.Tests/Polly.Extensions.Tests.csproj +++ b/test/Polly.Extensions.Tests/Polly.Extensions.Tests.csproj @@ -5,6 +5,7 @@ Test enable 100 + Exe [Polly.Extensions]* diff --git a/test/Polly.RateLimiting.Tests/Polly.RateLimiting.Tests.csproj b/test/Polly.RateLimiting.Tests/Polly.RateLimiting.Tests.csproj index 91ac01e7925..433b751f4f9 100644 --- a/test/Polly.RateLimiting.Tests/Polly.RateLimiting.Tests.csproj +++ b/test/Polly.RateLimiting.Tests/Polly.RateLimiting.Tests.csproj @@ -5,6 +5,7 @@ Test enable 100 + Exe [Polly.RateLimiting]* diff --git a/test/Polly.Specs/Helpers/Bulkhead/AnnotatedOutputHelper.cs b/test/Polly.Specs/Helpers/Bulkhead/AnnotatedOutputHelper.cs index fa61f84806e..ee798da4aa7 100644 --- a/test/Polly.Specs/Helpers/Bulkhead/AnnotatedOutputHelper.cs +++ b/test/Polly.Specs/Helpers/Bulkhead/AnnotatedOutputHelper.cs @@ -29,6 +29,8 @@ public Item(string format, object[] args) private readonly ITestOutputHelper _innerOutputHelper; + public string Output => _innerOutputHelper.Output; + public AnnotatedOutputHelper(ITestOutputHelper innerOutputHelper) => _innerOutputHelper = innerOutputHelper ?? throw new ArgumentNullException(nameof(innerOutputHelper)); diff --git a/test/Polly.Specs/Helpers/Bulkhead/SilentOutputHelper.cs b/test/Polly.Specs/Helpers/Bulkhead/SilentOutputHelper.cs index 2aa50df2883..8c1aca5bba8 100644 --- a/test/Polly.Specs/Helpers/Bulkhead/SilentOutputHelper.cs +++ b/test/Polly.Specs/Helpers/Bulkhead/SilentOutputHelper.cs @@ -2,6 +2,18 @@ public class SilentOutputHelper : ITestOutputHelper { + public string Output => string.Empty; + + public void Write(string message) + { + // Do nothing: intentionally silent. + } + + public void Write(string format, params object[] args) + { + // Do nothing: intentionally silent. + } + public void WriteLine(string message) { // Do nothing: intentionally silent. diff --git a/test/Polly.Specs/Polly.Specs.csproj b/test/Polly.Specs/Polly.Specs.csproj index 246fcbdaae6..ece34963d66 100644 --- a/test/Polly.Specs/Polly.Specs.csproj +++ b/test/Polly.Specs/Polly.Specs.csproj @@ -3,6 +3,7 @@ net8.0;net9.0 $(TargetFrameworks);net481 enable + Exe Test 94,94,91 [Polly]* @@ -21,7 +22,6 @@ - diff --git a/test/Polly.Testing.Tests/Polly.Testing.Tests.csproj b/test/Polly.Testing.Tests/Polly.Testing.Tests.csproj index 13f4e471abf..f355ea72111 100644 --- a/test/Polly.Testing.Tests/Polly.Testing.Tests.csproj +++ b/test/Polly.Testing.Tests/Polly.Testing.Tests.csproj @@ -5,6 +5,7 @@ Test enable 100 + Exe [Polly.Testing]* diff --git a/test/Shared/TestCancellation.cs b/test/Shared/TestCancellation.cs index be9cd8b0678..5396df4d754 100644 --- a/test/Shared/TestCancellation.cs +++ b/test/Shared/TestCancellation.cs @@ -1,6 +1,8 @@ +using Xunit; + namespace Polly; internal static class TestCancellation { - public static CancellationToken Token => CancellationToken.None; + public static CancellationToken Token => TestContext.Current.CancellationToken; } From 72c45bb9c9d2a2499f0001fc0a0441ad41d93da1 Mon Sep 17 00:00:00 2001 From: Martin Costello Date: Fri, 2 Jan 2026 15:15:38 +0000 Subject: [PATCH 2/6] Update package name Use `xunit.v3.mtp-v2` instead of `xunit.v3`. --- eng/Test.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Test.targets b/eng/Test.targets index 8a7839a611d..5f6d1d52a1b 100644 --- a/eng/Test.targets +++ b/eng/Test.targets @@ -19,7 +19,7 @@ - + From c0de1efa4796f65c8bed7d8c24b83573de149ff3 Mon Sep 17 00:00:00 2001 From: Martin Costello Date: Fri, 2 Jan 2026 15:16:13 +0000 Subject: [PATCH 3/6] Remove xunit.runner.visualstudio Remove now-redundant reference to xunit.runner.visualstudio. --- eng/Test.targets | 1 - 1 file changed, 1 deletion(-) diff --git a/eng/Test.targets b/eng/Test.targets index 5f6d1d52a1b..6029ca9c9ee 100644 --- a/eng/Test.targets +++ b/eng/Test.targets @@ -18,7 +18,6 @@ - From 9367477afc3d3619184eb2186ca1578f9809f665 Mon Sep 17 00:00:00 2001 From: Martin Costello Date: Fri, 2 Jan 2026 15:19:42 +0000 Subject: [PATCH 4/6] Remove redundant reference Remove redundant package reference. --- src/Snippets/Snippets.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Snippets/Snippets.csproj b/src/Snippets/Snippets.csproj index a1129258524..75c58f6df49 100644 --- a/src/Snippets/Snippets.csproj +++ b/src/Snippets/Snippets.csproj @@ -32,7 +32,6 @@ - From 92fd0e1bd99ec18f20cbd755efe1059d4773d2f8 Mon Sep 17 00:00:00 2001 From: Martin Costello Date: Fri, 2 Jan 2026 15:23:30 +0000 Subject: [PATCH 5/6] Fix mutation tests Switch to using FsCheck.Xunit.v3. --- Directory.Packages.props | 2 +- test/Polly.Core.Tests/Polly.Core.Tests.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 68a3f3b132b..d5b0802f807 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -4,7 +4,7 @@ - + diff --git a/test/Polly.Core.Tests/Polly.Core.Tests.csproj b/test/Polly.Core.Tests/Polly.Core.Tests.csproj index 8e8dae99757..e1216c4b1f2 100644 --- a/test/Polly.Core.Tests/Polly.Core.Tests.csproj +++ b/test/Polly.Core.Tests/Polly.Core.Tests.csproj @@ -16,7 +16,7 @@ - + From 27600157140200e9d473a7a2571ba2e03814889c Mon Sep 17 00:00:00 2001 From: Martin Costello Date: Fri, 2 Jan 2026 15:29:00 +0000 Subject: [PATCH 6/6] Disable MTP GitHubActionsTestLogger isn't strong-named which means MTP can't compile due to the strong-name requirement, so disable it. --- Directory.Packages.props | 3 ++- eng/Test.targets | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index d5b0802f807..965a22d5bca 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -38,8 +38,9 @@ + - + diff --git a/eng/Test.targets b/eng/Test.targets index 6029ca9c9ee..7d916c08284 100644 --- a/eng/Test.targets +++ b/eng/Test.targets @@ -18,7 +18,8 @@ - + +