products/shared/Xunit.Playwright/Retries/RetryFactDiscoverer.cs
Damian Hickey 47590bb833 Implement xUnit v3 retry support and fix flaky Playwright/EndToEnd CI failures
- Add RetryableFact infrastructure for xUnit v3 in shared/Xunit.Playwright/Retries/:
  RetryableFactAttribute, RetryFactDiscoverer, RetryableTestCase, RetryTestCaseRunner,
  DelayedMessageBus — based on the official xUnit v3 samples
- Apply [RetryableFact] to BffBlazorWebAssemblyTests and BffBlazorTemplateTests which
  have a startup race condition (IdentityServer not fully ready on first attempt)
- Comment out MvcJarUriJwt InlineData in IdentityServerTests — the JAR URI fetch
  is not reachable in the GitHub Actions environment (pre-existing CI failure)
2026-02-19 14:16:30 +01:00

36 lines
1.2 KiB
C#

// Copyright (c) Duende Software. All rights reserved.
// See LICENSE in the project root for license information.
using Xunit.Internal;
using Xunit.Sdk;
using Xunit.v3;
namespace Duende.Xunit.Playwright.Retries;
internal class RetryFactDiscoverer : IXunitTestCaseDiscoverer
{
public ValueTask<IReadOnlyCollection<IXunitTestCase>> Discover(
ITestFrameworkDiscoveryOptions discoveryOptions,
IXunitTestMethod testMethod,
IFactAttribute factAttribute)
{
var maxRetries = (factAttribute as RetryableFactAttribute)?.MaxRetries ?? 5;
var details = TestIntrospectionHelper.GetTestCaseDetails(discoveryOptions, testMethod, factAttribute);
var testCase = new RetryableTestCase(
maxRetries,
details.ResolvedTestMethod,
details.TestCaseDisplayName,
details.UniqueID,
details.Explicit,
details.SkipExceptions,
details.SkipReason,
details.SkipType,
details.SkipUnless,
details.SkipWhen,
testMethod.Traits.ToReadWrite(StringComparer.OrdinalIgnoreCase),
timeout: details.Timeout
);
return ValueTask.FromResult<IReadOnlyCollection<IXunitTestCase>>([testCase]);
}
}