diff --git a/Directory.Packages.props b/Directory.Packages.props
index ab4e81320..0ca6e3bd5 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -39,7 +39,6 @@
-
@@ -54,7 +53,7 @@
-
+
@@ -98,10 +97,10 @@
-
-
-
+
+
+
@@ -117,13 +116,13 @@
-
+
-
+
@@ -131,10 +130,11 @@
-
-
-
-
+
+
+
+
+
diff --git a/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/AspNetCore.Authentication.JwtBearer.Tests.csproj b/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/AspNetCore.Authentication.JwtBearer.Tests.csproj
index 7510e9702..6f6c1483e 100644
--- a/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/AspNetCore.Authentication.JwtBearer.Tests.csproj
+++ b/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/AspNetCore.Authentication.JwtBearer.Tests.csproj
@@ -16,7 +16,7 @@
-
+
diff --git a/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/DPoPIntegrationTests.cs b/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/DPoPIntegrationTests.cs
index 753d455b9..16ce9f89b 100644
--- a/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/DPoPIntegrationTests.cs
+++ b/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/DPoPIntegrationTests.cs
@@ -16,7 +16,6 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Tokens;
using Microsoft.Net.Http.Headers;
-using Xunit.Abstractions;
namespace Duende.AspNetCore.Authentication.JwtBearer;
diff --git a/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/ApiHost.cs b/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/ApiHost.cs
index 85d1eaf93..9c2a02c5b 100644
--- a/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/ApiHost.cs
+++ b/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/ApiHost.cs
@@ -4,7 +4,6 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
-using Xunit.Abstractions;
namespace Duende.AspNetCore.TestFramework;
diff --git a/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/AppHost.cs b/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/AppHost.cs
index 59291dae1..513ed6823 100644
--- a/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/AppHost.cs
+++ b/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/AppHost.cs
@@ -11,7 +11,6 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using RichardSzalay.MockHttp;
-using Xunit.Abstractions;
namespace Duende.AspNetCore.TestFramework;
diff --git a/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/GenericHost.cs b/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/GenericHost.cs
index 52cd9c766..d78dae633 100644
--- a/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/GenericHost.cs
+++ b/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/GenericHost.cs
@@ -4,13 +4,12 @@
using System.Net;
using System.Reflection;
using System.Security.Claims;
-using Meziantou.Extensions.Logging.Xunit;
+using MartinCostello.Logging.XUnit;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
-using Xunit.Abstractions;
namespace Duende.AspNetCore.TestFramework;
@@ -104,7 +103,7 @@ public class GenericHost
private void ConfigureServices(IServiceCollection services)
{
// This adds log messages to the output of our tests when they fail.
- // See https://www.meziantou.net/how-to-view-logs-from-ilogger-in-xunitdotnet.htm
+ // See https://github.com/martincostello/xunit-logging
services.AddLogging(options =>
{
// If you need different log output to understand a test failure, configure it here
@@ -113,10 +112,7 @@ public class GenericHost
options.AddFilter("Duende.IdentityServer.License", LogLevel.Error);
options.AddFilter("Duende.IdentityServer.Startup", LogLevel.Error);
- options.AddProvider(new XUnitLoggerProvider(_testOutputHelper, new XUnitLoggerOptions
- {
- IncludeCategory = true,
- }));
+ options.AddXUnit(_testOutputHelper);
});
OnConfigureServices(services);
diff --git a/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/IdentityServerHost.cs b/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/IdentityServerHost.cs
index 2a00c1d51..06a7578c6 100644
--- a/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/IdentityServerHost.cs
+++ b/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/IdentityServerHost.cs
@@ -9,7 +9,6 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.JsonWebTokens;
using Microsoft.IdentityModel.Tokens;
-using Xunit.Abstractions;
namespace Duende.AspNetCore.TestFramework;
diff --git a/bff/test/Bff.Blazor.Client.UnitTests/Bff.Blazor.Client.UnitTests.csproj b/bff/test/Bff.Blazor.Client.UnitTests/Bff.Blazor.Client.UnitTests.csproj
index f689b39ae..e3be98335 100644
--- a/bff/test/Bff.Blazor.Client.UnitTests/Bff.Blazor.Client.UnitTests.csproj
+++ b/bff/test/Bff.Blazor.Client.UnitTests/Bff.Blazor.Client.UnitTests.csproj
@@ -13,7 +13,7 @@
-
+
diff --git a/bff/test/Bff.Blazor.UnitTests/Bff.Blazor.UnitTests.csproj b/bff/test/Bff.Blazor.UnitTests/Bff.Blazor.UnitTests.csproj
index 70ab36c55..7d12ae238 100644
--- a/bff/test/Bff.Blazor.UnitTests/Bff.Blazor.UnitTests.csproj
+++ b/bff/test/Bff.Blazor.UnitTests/Bff.Blazor.UnitTests.csproj
@@ -3,28 +3,16 @@
enable
enable
-
false
true
True
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -32,4 +20,8 @@
+
+
+
+
diff --git a/bff/test/Bff.Blazor.UnitTests/BffBlazorTests.cs b/bff/test/Bff.Blazor.UnitTests/BffBlazorTests.cs
index 374808170..669cffc42 100644
--- a/bff/test/Bff.Blazor.UnitTests/BffBlazorTests.cs
+++ b/bff/test/Bff.Blazor.UnitTests/BffBlazorTests.cs
@@ -6,7 +6,6 @@ using Duende.Bff;
using Duende.Bff.Tests.TestHosts;
using Duende.IdentityServer.Models;
using Duende.IdentityServer.Services;
-using Xunit.Abstractions;
namespace Bff.Blazor.UnitTests;
@@ -70,7 +69,7 @@ public class BffBlazorTests : OutputWritingTestBase
response.StatusCode.ShouldBe(HttpStatusCode.OK);
}
- public override async Task InitializeAsync()
+ public override async ValueTask InitializeAsync()
{
await IdentityServerHost.InitializeAsync();
await ApiHost.InitializeAsync();
@@ -78,7 +77,7 @@ public class BffBlazorTests : OutputWritingTestBase
await base.InitializeAsync();
}
- public override async Task DisposeAsync()
+ public override async ValueTask DisposeAsync()
{
await ApiHost.DisposeAsync();
await BffHost.DisposeAsync();
diff --git a/bff/test/Bff.EntityFramework.Tests/Bff.EntityFramework.Tests.csproj b/bff/test/Bff.EntityFramework.Tests/Bff.EntityFramework.Tests.csproj
index 79ed98191..155a1b68a 100644
--- a/bff/test/Bff.EntityFramework.Tests/Bff.EntityFramework.Tests.csproj
+++ b/bff/test/Bff.EntityFramework.Tests/Bff.EntityFramework.Tests.csproj
@@ -7,8 +7,9 @@
-
+
+
diff --git a/bff/test/Bff.Tests/Bff.Tests.csproj b/bff/test/Bff.Tests/Bff.Tests.csproj
index 410da7cb8..ae3294105 100644
--- a/bff/test/Bff.Tests/Bff.Tests.csproj
+++ b/bff/test/Bff.Tests/Bff.Tests.csproj
@@ -11,7 +11,7 @@
-
+
diff --git a/bff/test/Bff.Tests/Endpoints/DpopRemoteEndpointTests.cs b/bff/test/Bff.Tests/Endpoints/DpopRemoteEndpointTests.cs
index 87d0c340a..bfc8091f0 100644
--- a/bff/test/Bff.Tests/Endpoints/DpopRemoteEndpointTests.cs
+++ b/bff/test/Bff.Tests/Endpoints/DpopRemoteEndpointTests.cs
@@ -7,7 +7,6 @@ using Duende.Bff.Tests.TestFramework;
using Duende.Bff.Tests.TestHosts;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Tokens;
-using Xunit.Abstractions;
namespace Duende.Bff.Tests.Endpoints;
diff --git a/bff/test/Bff.Tests/Endpoints/LocalEndpointTests.cs b/bff/test/Bff.Tests/Endpoints/LocalEndpointTests.cs
index 9e31b3b3b..59a6f5bdb 100644
--- a/bff/test/Bff.Tests/Endpoints/LocalEndpointTests.cs
+++ b/bff/test/Bff.Tests/Endpoints/LocalEndpointTests.cs
@@ -6,7 +6,6 @@ using System.Net.Http.Json;
using Duende.Bff.Tests.TestFramework;
using Duende.Bff.Tests.TestHosts;
using Microsoft.Extensions.DependencyInjection;
-using Xunit.Abstractions;
namespace Duende.Bff.Tests.Endpoints;
diff --git a/bff/test/Bff.Tests/Endpoints/Management/BackchannelLogoutEndpointTests.cs b/bff/test/Bff.Tests/Endpoints/Management/BackchannelLogoutEndpointTests.cs
index ee2d0f4ab..79ff7710b 100644
--- a/bff/test/Bff.Tests/Endpoints/Management/BackchannelLogoutEndpointTests.cs
+++ b/bff/test/Bff.Tests/Endpoints/Management/BackchannelLogoutEndpointTests.cs
@@ -4,7 +4,6 @@
using System.Net;
using Duende.Bff.Tests.TestHosts;
using Microsoft.Extensions.DependencyInjection;
-using Xunit.Abstractions;
namespace Duende.Bff.Tests.Endpoints.Management;
diff --git a/bff/test/Bff.Tests/Endpoints/Management/LoginEndpointTests.cs b/bff/test/Bff.Tests/Endpoints/Management/LoginEndpointTests.cs
index d7858483e..772a892e3 100644
--- a/bff/test/Bff.Tests/Endpoints/Management/LoginEndpointTests.cs
+++ b/bff/test/Bff.Tests/Endpoints/Management/LoginEndpointTests.cs
@@ -4,7 +4,6 @@
using System.Net;
using Duende.Bff.Tests.TestHosts;
using Microsoft.Extensions.DependencyInjection;
-using Xunit.Abstractions;
namespace Duende.Bff.Tests.Endpoints.Management;
diff --git a/bff/test/Bff.Tests/Endpoints/Management/LogoutEndpointTests.cs b/bff/test/Bff.Tests/Endpoints/Management/LogoutEndpointTests.cs
index 53e915d98..495868e5b 100644
--- a/bff/test/Bff.Tests/Endpoints/Management/LogoutEndpointTests.cs
+++ b/bff/test/Bff.Tests/Endpoints/Management/LogoutEndpointTests.cs
@@ -4,7 +4,6 @@
using System.Net;
using Duende.Bff.Tests.TestHosts;
using Microsoft.Extensions.DependencyInjection;
-using Xunit.Abstractions;
namespace Duende.Bff.Tests.Endpoints.Management;
diff --git a/bff/test/Bff.Tests/Endpoints/Management/ManagementBasePathTests.cs b/bff/test/Bff.Tests/Endpoints/Management/ManagementBasePathTests.cs
index 978d3eef5..56ac084c0 100644
--- a/bff/test/Bff.Tests/Endpoints/Management/ManagementBasePathTests.cs
+++ b/bff/test/Bff.Tests/Endpoints/Management/ManagementBasePathTests.cs
@@ -5,7 +5,6 @@ using System.Net;
using Duende.Bff.Tests.TestHosts;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
-using Xunit.Abstractions;
namespace Duende.Bff.Tests.Endpoints.Management;
diff --git a/bff/test/Bff.Tests/Endpoints/Management/UserEndpointTests.cs b/bff/test/Bff.Tests/Endpoints/Management/UserEndpointTests.cs
index cc3b1afac..8f74f157c 100644
--- a/bff/test/Bff.Tests/Endpoints/Management/UserEndpointTests.cs
+++ b/bff/test/Bff.Tests/Endpoints/Management/UserEndpointTests.cs
@@ -4,7 +4,6 @@
using System.Net;
using System.Security.Claims;
using Duende.Bff.Tests.TestHosts;
-using Xunit.Abstractions;
namespace Duende.Bff.Tests.Endpoints.Management;
diff --git a/bff/test/Bff.Tests/Endpoints/RemoteEndpointTests.cs b/bff/test/Bff.Tests/Endpoints/RemoteEndpointTests.cs
index dcc54da0a..101777b75 100644
--- a/bff/test/Bff.Tests/Endpoints/RemoteEndpointTests.cs
+++ b/bff/test/Bff.Tests/Endpoints/RemoteEndpointTests.cs
@@ -6,7 +6,6 @@ using System.Net.Http.Json;
using System.Text.Json;
using Duende.Bff.Tests.TestFramework;
using Duende.Bff.Tests.TestHosts;
-using Xunit.Abstractions;
namespace Duende.Bff.Tests.Endpoints;
diff --git a/bff/test/Bff.Tests/Endpoints/YarpRemoteEndpointTests.cs b/bff/test/Bff.Tests/Endpoints/YarpRemoteEndpointTests.cs
index d2083f76d..c9ab188d5 100644
--- a/bff/test/Bff.Tests/Endpoints/YarpRemoteEndpointTests.cs
+++ b/bff/test/Bff.Tests/Endpoints/YarpRemoteEndpointTests.cs
@@ -4,7 +4,6 @@
using System.Net;
using Duende.Bff.Tests.TestFramework;
using Duende.Bff.Tests.TestHosts;
-using Xunit.Abstractions;
namespace Duende.Bff.Tests.Endpoints;
diff --git a/bff/test/Bff.Tests/GenericHostTests.cs b/bff/test/Bff.Tests/GenericHostTests.cs
index fce77081f..34cfbd39b 100644
--- a/bff/test/Bff.Tests/GenericHostTests.cs
+++ b/bff/test/Bff.Tests/GenericHostTests.cs
@@ -4,7 +4,6 @@
using System.Net;
using Duende.Bff.Tests.TestFramework;
using Microsoft.AspNetCore.Builder;
-using Xunit.Abstractions;
namespace Duende.Bff.Tests;
diff --git a/bff/test/Bff.Tests/Headers/ApiAndBffUseForwardedHeaders.cs b/bff/test/Bff.Tests/Headers/ApiAndBffUseForwardedHeaders.cs
index 00de4fef2..6a0fd2fc7 100644
--- a/bff/test/Bff.Tests/Headers/ApiAndBffUseForwardedHeaders.cs
+++ b/bff/test/Bff.Tests/Headers/ApiAndBffUseForwardedHeaders.cs
@@ -4,7 +4,6 @@
using System.Text.Json;
using Duende.Bff.Tests.TestFramework;
using Duende.Bff.Tests.TestHosts;
-using Xunit.Abstractions;
namespace Duende.Bff.Tests.Headers;
diff --git a/bff/test/Bff.Tests/Headers/ApiUseForwardedHeaders.cs b/bff/test/Bff.Tests/Headers/ApiUseForwardedHeaders.cs
index 3f0572751..c003ea57b 100644
--- a/bff/test/Bff.Tests/Headers/ApiUseForwardedHeaders.cs
+++ b/bff/test/Bff.Tests/Headers/ApiUseForwardedHeaders.cs
@@ -4,7 +4,6 @@
using System.Text.Json;
using Duende.Bff.Tests.TestFramework;
using Duende.Bff.Tests.TestHosts;
-using Xunit.Abstractions;
namespace Duende.Bff.Tests.Headers;
diff --git a/bff/test/Bff.Tests/Headers/General.cs b/bff/test/Bff.Tests/Headers/General.cs
index da5f1c6ad..b979d2e7e 100644
--- a/bff/test/Bff.Tests/Headers/General.cs
+++ b/bff/test/Bff.Tests/Headers/General.cs
@@ -4,7 +4,6 @@
using System.Text.Json;
using Duende.Bff.Tests.TestFramework;
using Duende.Bff.Tests.TestHosts;
-using Xunit.Abstractions;
namespace Duende.Bff.Tests.Headers;
diff --git a/bff/test/Bff.Tests/IAccessTokenRetriever_Extensibility_tests.cs b/bff/test/Bff.Tests/IAccessTokenRetriever_Extensibility_tests.cs
index 823f9c05f..6351293d1 100644
--- a/bff/test/Bff.Tests/IAccessTokenRetriever_Extensibility_tests.cs
+++ b/bff/test/Bff.Tests/IAccessTokenRetriever_Extensibility_tests.cs
@@ -6,7 +6,6 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
-using Xunit.Abstractions;
namespace Duende.Bff.Tests;
diff --git a/bff/test/Bff.Tests/SessionManagement/CookieSlidingTests.cs b/bff/test/Bff.Tests/SessionManagement/CookieSlidingTests.cs
index c9d151574..7451766c5 100644
--- a/bff/test/Bff.Tests/SessionManagement/CookieSlidingTests.cs
+++ b/bff/test/Bff.Tests/SessionManagement/CookieSlidingTests.cs
@@ -5,7 +5,6 @@ using Duende.Bff.Tests.TestHosts;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Time.Testing;
-using Xunit.Abstractions;
namespace Duende.Bff.Tests.SessionManagement;
diff --git a/bff/test/Bff.Tests/SessionManagement/RevokeRefreshTokenTests.cs b/bff/test/Bff.Tests/SessionManagement/RevokeRefreshTokenTests.cs
index 2a15d9703..9e2dd28bc 100644
--- a/bff/test/Bff.Tests/SessionManagement/RevokeRefreshTokenTests.cs
+++ b/bff/test/Bff.Tests/SessionManagement/RevokeRefreshTokenTests.cs
@@ -4,7 +4,6 @@
using Duende.Bff.Tests.TestHosts;
using Duende.IdentityServer.Stores;
using Microsoft.Extensions.DependencyInjection;
-using Xunit.Abstractions;
namespace Duende.Bff.Tests.SessionManagement;
diff --git a/bff/test/Bff.Tests/SessionManagement/ServerSideTicketStoreTests.cs b/bff/test/Bff.Tests/SessionManagement/ServerSideTicketStoreTests.cs
index 019884a79..55f623e6b 100644
--- a/bff/test/Bff.Tests/SessionManagement/ServerSideTicketStoreTests.cs
+++ b/bff/test/Bff.Tests/SessionManagement/ServerSideTicketStoreTests.cs
@@ -3,7 +3,6 @@
using Duende.Bff.Tests.TestHosts;
using Microsoft.Extensions.DependencyInjection;
-using Xunit.Abstractions;
namespace Duende.Bff.Tests.SessionManagement;
diff --git a/bff/test/Bff.Tests/TestFramework/GenericHost.cs b/bff/test/Bff.Tests/TestFramework/GenericHost.cs
index f605405b0..9f0bc70ca 100644
--- a/bff/test/Bff.Tests/TestFramework/GenericHost.cs
+++ b/bff/test/Bff.Tests/TestFramework/GenericHost.cs
@@ -46,7 +46,7 @@ public class GenericHost(WriteTestOutput writeOutput, string baseAddress = "http
return _baseAddress + path;
}
- public async Task InitializeAsync()
+ public async ValueTask InitializeAsync()
{
var hostBuilder = new HostBuilder()
.ConfigureWebHost(builder =>
diff --git a/bff/test/Bff.Tests/TestHosts/BffIntegrationTestBase.cs b/bff/test/Bff.Tests/TestHosts/BffIntegrationTestBase.cs
index e8d908da8..3069fcc2a 100644
--- a/bff/test/Bff.Tests/TestHosts/BffIntegrationTestBase.cs
+++ b/bff/test/Bff.Tests/TestHosts/BffIntegrationTestBase.cs
@@ -6,7 +6,6 @@ using Duende.IdentityServer.Models;
using Duende.IdentityServer.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
-using Xunit.Abstractions;
namespace Duende.Bff.Tests.TestHosts;
@@ -52,7 +51,7 @@ public class BffIntegrationTestBase : OutputWritingTestBase
public async Task Login(string sub) => await IdentityServerHost.IssueSessionCookieAsync(new Claim("sub", sub));
- public override async Task InitializeAsync()
+ public override async ValueTask InitializeAsync()
{
await IdentityServerHost.InitializeAsync();
await ApiHost.InitializeAsync();
@@ -61,7 +60,7 @@ public class BffIntegrationTestBase : OutputWritingTestBase
await base.InitializeAsync();
}
- public override async Task DisposeAsync()
+ public override async ValueTask DisposeAsync()
{
await ApiHost.DisposeAsync();
await BffHost.DisposeAsync();
diff --git a/bff/test/Bff.Tests/TestHosts/OutputWritingTestBase.cs b/bff/test/Bff.Tests/TestHosts/OutputWritingTestBase.cs
index 4a7134495..a7c6a1932 100644
--- a/bff/test/Bff.Tests/TestHosts/OutputWritingTestBase.cs
+++ b/bff/test/Bff.Tests/TestHosts/OutputWritingTestBase.cs
@@ -2,7 +2,6 @@
// See LICENSE in the project root for license information.
using System.Text;
-using Xunit.Abstractions;
namespace Duende.Bff.Tests.TestHosts;
@@ -18,9 +17,9 @@ public class OutputWritingTestBase(ITestOutputHelper testOutputHelper) : IAsyncL
}
}
- public virtual Task InitializeAsync() => Task.CompletedTask;
+ public virtual ValueTask InitializeAsync() => default;
- public virtual Task DisposeAsync()
+ public virtual ValueTask DisposeAsync()
{
lock (_output)
{
@@ -28,6 +27,6 @@ public class OutputWritingTestBase(ITestOutputHelper testOutputHelper) : IAsyncL
}
- return Task.CompletedTask;
+ return default;
}
}
diff --git a/bff/test/Bff.Tests/TestHosts/YarpBffIntegrationTestBase.cs b/bff/test/Bff.Tests/TestHosts/YarpBffIntegrationTestBase.cs
index 5a8ffa664..bc736c6bf 100644
--- a/bff/test/Bff.Tests/TestHosts/YarpBffIntegrationTestBase.cs
+++ b/bff/test/Bff.Tests/TestHosts/YarpBffIntegrationTestBase.cs
@@ -6,7 +6,6 @@ using Duende.IdentityServer.Models;
using Duende.IdentityServer.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
-using Xunit.Abstractions;
namespace Duende.Bff.Tests.TestHosts;
@@ -51,7 +50,7 @@ public class YarpBffIntegrationTestBase : OutputWritingTestBase
public async Task Login(string sub) => await _identityServerHost.IssueSessionCookieAsync(new Claim("sub", sub));
- public override async Task InitializeAsync()
+ public override async ValueTask InitializeAsync()
{
await _identityServerHost.InitializeAsync();
await ApiHost.InitializeAsync();
@@ -60,7 +59,7 @@ public class YarpBffIntegrationTestBase : OutputWritingTestBase
await base.InitializeAsync();
}
- public override async Task DisposeAsync()
+ public override async ValueTask DisposeAsync()
{
await _identityServerHost.DisposeAsync();
await ApiHost.DisposeAsync();
diff --git a/bff/test/Hosts.Tests/BffBlazorWebAssemblyTests.cs b/bff/test/Hosts.Tests/BffBlazorWebAssemblyTests.cs
index 728e0bcde..2b35ce75d 100644
--- a/bff/test/Hosts.Tests/BffBlazorWebAssemblyTests.cs
+++ b/bff/test/Hosts.Tests/BffBlazorWebAssemblyTests.cs
@@ -4,7 +4,6 @@
using Hosts.ServiceDefaults;
using Hosts.Tests.PageModels;
using Hosts.Tests.TestInfra;
-using Xunit.Abstractions;
namespace Hosts.Tests;
@@ -20,7 +19,7 @@ public class BffBlazorWebAssemblyTests(ITestOutputHelper output, AppHostFixture
};
}
- [SkippableFact]
+ [Fact]
public async Task Can_login_and_load_local_api()
{
await Warmup();
diff --git a/bff/test/Hosts.Tests/BffTests.cs b/bff/test/Hosts.Tests/BffTests.cs
index fb8e79c6f..49aff2a16 100644
--- a/bff/test/Hosts.Tests/BffTests.cs
+++ b/bff/test/Hosts.Tests/BffTests.cs
@@ -3,7 +3,6 @@
using Hosts.ServiceDefaults;
using Hosts.Tests.TestInfra;
-using Xunit.Abstractions;
namespace Hosts.Tests;
@@ -18,14 +17,14 @@ public class BffTests : IntegrationTestBase
_bffClient = new BffClient(CreateHttpClient(AppHostServices.Bff));
}
- [SkippableFact]
+ [Fact]
public async Task Can_invoke_home()
{
var response = await _httpClient.GetAsync("/");
response.StatusCode.ShouldBe(HttpStatusCode.OK);
}
- [SkippableFact]
+ [Fact]
public async Task Can_initiate_login()
{
@@ -39,7 +38,7 @@ public class BffTests : IntegrationTestBase
claims.Any().ShouldBeTrue();
}
- [SkippableTheory]
+ [Theory]
[InlineData("/local/self-contained")]
[InlineData("/local/invokes-external-api")]
[InlineData("/api/user-token")]
@@ -55,7 +54,7 @@ public class BffTests : IntegrationTestBase
await _bffClient.InvokeApi(url);
}
- [SkippableFact]
+ [Fact]
public async Task Can_logout()
{
await _bffClient.TriggerLogin();
diff --git a/bff/test/Hosts.Tests/BlazorPerComponentTests.cs b/bff/test/Hosts.Tests/BlazorPerComponentTests.cs
index 2ce60b061..cfa2f8611 100644
--- a/bff/test/Hosts.Tests/BlazorPerComponentTests.cs
+++ b/bff/test/Hosts.Tests/BlazorPerComponentTests.cs
@@ -4,7 +4,6 @@
using Hosts.ServiceDefaults;
using Hosts.Tests.PageModels;
using Hosts.Tests.TestInfra;
-using Xunit.Abstractions;
namespace Hosts.Tests;
@@ -21,7 +20,7 @@ public class BlazorPerComponentTests(ITestOutputHelper output, AppHostFixture fi
};
}
- [SkippableFact]
+ [Fact]
public async Task Can_load_blazor_webassembly_app()
{
await Warmup();
diff --git a/bff/test/Hosts.Tests/Hosts.Tests.csproj b/bff/test/Hosts.Tests/Hosts.Tests.csproj
index c21f38cb0..2273d4860 100644
--- a/bff/test/Hosts.Tests/Hosts.Tests.csproj
+++ b/bff/test/Hosts.Tests/Hosts.Tests.csproj
@@ -13,30 +13,25 @@
-
+
-
+
-
-
-
-
+
-
-
-
-
-
+
+
+
diff --git a/bff/test/Hosts.Tests/PlaywrightTestBase.cs b/bff/test/Hosts.Tests/PlaywrightTestBase.cs
index 939512f76..6bf0f94be 100644
--- a/bff/test/Hosts.Tests/PlaywrightTestBase.cs
+++ b/bff/test/Hosts.Tests/PlaywrightTestBase.cs
@@ -4,9 +4,8 @@
using System.Reflection;
using Hosts.Tests.TestInfra;
using Microsoft.Playwright;
-using Microsoft.Playwright.Xunit;
-using Xunit.Abstractions;
-using Xunit.Sdk;
+using Microsoft.Playwright.Xunit.v3;
+using Xunit.v3;
namespace Hosts.Tests;
@@ -31,12 +30,12 @@ public class PlaywrightTestBase : PageTest, IDisposable
#if DEBUG_NCRUNCH
// Running in NCrunch. NCrunch cannot build the aspire project, so it needs
// to be started manually.
- Skip.If(true, "When running the Host.Tests using NCrunch, you must start the Hosts.AppHost project manually. IE: dotnet run -p bff/samples/Hosts.AppHost. Or start without debugging from the UI. ");
+ Assert.Skip("When running the Host.Tests using NCrunch, you must start the Hosts.AppHost project manually. IE: dotnet run -p bff/samples/Hosts.AppHost. Or start without debugging from the UI. ");
#endif
}
}
- public override async Task InitializeAsync()
+ public async ValueTask InitializeAsync()
{
await base.InitializeAsync();
Context.SetDefaultTimeout(10_000);
@@ -49,7 +48,7 @@ public class PlaywrightTestBase : PageTest, IDisposable
});
}
- public override async Task DisposeAsync()
+ public override async ValueTask DisposeAsync()
{
var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? Environment.CurrentDirectory;
// if path ends with /bin/{build configuration}/{dotnetversion}, then strip that from the path.
@@ -106,18 +105,17 @@ public class PlaywrightTestBase : PageTest, IDisposable
public HttpClient CreateHttpClient(string clientName) => Fixture.CreateHttpClient(clientName);
}
-public class WithTestNameAttribute : BeforeAfterTestAttribute
+public class WithTestNameAttribute : Attribute, IBeforeAfterTestAttribute
{
public static string CurrentTestName = string.Empty;
public static string CurrentClassName = string.Empty;
- public override void Before(MethodInfo methodInfo)
+ public void Before(MethodInfo methodInfo, IXunitTest _)
{
CurrentTestName = methodInfo.Name;
CurrentClassName = methodInfo.DeclaringType!.Name;
}
- public override void After(MethodInfo methodInfo)
- {
- }
+ public void After(MethodInfo methodInfo, IXunitTest _)
+ { }
}
diff --git a/bff/test/Hosts.Tests/TestInfra/AppHostFixture.cs b/bff/test/Hosts.Tests/TestInfra/AppHostFixture.cs
index 701d26262..2ebc4e593 100644
--- a/bff/test/Hosts.Tests/TestInfra/AppHostFixture.cs
+++ b/bff/test/Hosts.Tests/TestInfra/AppHostFixture.cs
@@ -51,7 +51,7 @@ public class AppHostFixture : IAsyncLifetime
public bool UsingAlreadyRunningInstance { get; private set; }
public string StartupLogs => _startupLogs.ToString() ?? string.Empty;
- public async Task InitializeAsync()
+ public async ValueTask InitializeAsync()
{
using var startupLogWriter = ConnectLogger(s => _startupLogs.Write(s));
@@ -130,7 +130,7 @@ public class AppHostFixture : IAsyncLifetime
}
- public async Task DisposeAsync()
+ public async ValueTask DisposeAsync()
{
if (_app != null)
{
@@ -272,7 +272,7 @@ public class AppHostFixture : IAsyncLifetime
return _app.GetEndpoint(clientName);
#else
- Skip.If(true, "When running the Host.Tests using NCrunch, you must start the Hosts.AppHost project manually. IE: dotnet run -p bff/samples/Hosts.AppHost. Or start without debugging from the UI. ");
+ Assert.Skip("When running the Host.Tests using NCrunch, you must start the Hosts.AppHost project manually. IE: dotnet run -p bff/samples/Hosts.AppHost. Or start without debugging from the UI. ");
return null!;
#endif
}
diff --git a/bff/test/Hosts.Tests/TestInfra/IntegrationTestBase.cs b/bff/test/Hosts.Tests/TestInfra/IntegrationTestBase.cs
index c0c0cfbe1..bc1857044 100644
--- a/bff/test/Hosts.Tests/TestInfra/IntegrationTestBase.cs
+++ b/bff/test/Hosts.Tests/TestInfra/IntegrationTestBase.cs
@@ -1,7 +1,6 @@
// Copyright (c) Duende Software. All rights reserved.
// See LICENSE in the project root for license information.
-using Xunit.Abstractions;
namespace Hosts.Tests.TestInfra;
@@ -24,7 +23,7 @@ public class IntegrationTestBase : IDisposable
#if DEBUG_NCRUNCH
// Running in NCrunch. NCrunch cannot build the aspire project, so it needs
// to be started manually.
- Skip.If(true, "When running the Host.Tests using NCrunch, you must start the Hosts.AppHost project manually. IE: dotnet run -p bff/samples/Hosts.AppHost. Or start without debugging from the UI. ");
+ Assert.Skip("When running the Host.Tests using NCrunch, you must start the Hosts.AppHost project manually. IE: dotnet run -p bff/samples/Hosts.AppHost. Or start without debugging from the UI. ");
#endif
}
}
diff --git a/identity-server/test/IdentityServer.EndToEndTests/IdentityServer.EndToEndTests.csproj b/identity-server/test/IdentityServer.EndToEndTests/IdentityServer.EndToEndTests.csproj
index 33d7e410a..2c592fec7 100644
--- a/identity-server/test/IdentityServer.EndToEndTests/IdentityServer.EndToEndTests.csproj
+++ b/identity-server/test/IdentityServer.EndToEndTests/IdentityServer.EndToEndTests.csproj
@@ -12,11 +12,9 @@
-
+
-
-
diff --git a/identity-server/test/IdentityServer.EndToEndTests/IdentityServerTests.cs b/identity-server/test/IdentityServer.EndToEndTests/IdentityServerTests.cs
index 786de6519..069ce961c 100644
--- a/identity-server/test/IdentityServer.EndToEndTests/IdentityServerTests.cs
+++ b/identity-server/test/IdentityServer.EndToEndTests/IdentityServerTests.cs
@@ -5,7 +5,6 @@ using Duende.IdentityServer.EndToEndTests.TestInfra;
using Duende.Xunit.Playwright;
using Projects;
using ServiceDefaults;
-using Xunit.Abstractions;
namespace Duende.IdentityServer.EndToEndTests;
diff --git a/identity-server/test/IdentityServer.EndToEndTests/TestInfra/IdentityServerPlaywrightTestBase.cs b/identity-server/test/IdentityServer.EndToEndTests/TestInfra/IdentityServerPlaywrightTestBase.cs
index 1139da7f9..07f4902a4 100644
--- a/identity-server/test/IdentityServer.EndToEndTests/TestInfra/IdentityServerPlaywrightTestBase.cs
+++ b/identity-server/test/IdentityServer.EndToEndTests/TestInfra/IdentityServerPlaywrightTestBase.cs
@@ -3,7 +3,6 @@
using Duende.Xunit.Playwright;
using Projects;
-using Xunit.Abstractions;
namespace Duende.IdentityServer.EndToEndTests.TestInfra;
diff --git a/identity-server/test/IdentityServer.IntegrationTests/EntityFramework/IntegrationTest.cs b/identity-server/test/IdentityServer.IntegrationTests/EntityFramework/IntegrationTest.cs
index c250a5077..71ae791c9 100644
--- a/identity-server/test/IdentityServer.IntegrationTests/EntityFramework/IntegrationTest.cs
+++ b/identity-server/test/IdentityServer.IntegrationTests/EntityFramework/IntegrationTest.cs
@@ -2,6 +2,7 @@
// See LICENSE in the project root for license information.
+using System.Linq;
using System.Runtime.InteropServices;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
@@ -50,5 +51,6 @@ public class IntegrationTest : IClassFixture fixture) => fixture.Options = TestDatabaseProviders.ToList>();
+ protected IntegrationTest(DatabaseProviderFixture fixture)
+ => fixture.Options = TestDatabaseProviders.Select(row => row.Data).ToList();
}
diff --git a/identity-server/test/IdentityServer.IntegrationTests/EntityFramework/Storage/Stores/ClientStoreTests.cs b/identity-server/test/IdentityServer.IntegrationTests/EntityFramework/Storage/Stores/ClientStoreTests.cs
index 1d0a039e7..dbe0d7063 100644
--- a/identity-server/test/IdentityServer.IntegrationTests/EntityFramework/Storage/Stores/ClientStoreTests.cs
+++ b/identity-server/test/IdentityServer.IntegrationTests/EntityFramework/Storage/Stores/ClientStoreTests.cs
@@ -167,7 +167,7 @@ public class ClientStoreTests : IntegrationTest
@@ -133,9 +133,7 @@ public class DynamicProvidersTests
await ctx.SignInAsync(new IdentityServerUser("2").CreatePrincipal());
});
};
- _idp2.InitializeAsync().Wait();
-
-
+ _idp2.InitializeAsync().AsTask().Wait();
_host = new GenericHost("https://server");
_host.OnConfigureServices += services =>
@@ -403,21 +401,15 @@ public class DynamicProvidersTests
public override string ToString() => Name;
}
- private class DynamicProviderConfigurationData : TheoryData
+ private sealed class DynamicProviderConfigurationData : TheoryData
{
public DynamicProviderConfigurationData()
{
- Add(new("Default PathPrefix", _ => { }));
- Add(new("PathPrefix Callback",
- options => options.DynamicProviders.PathMatchingCallback = ctx =>
- {
- if (ctx.Request.Path.StartsWithSegments("/federation/idp1", StringComparison.InvariantCulture))
- {
- return Task.FromResult("idp1");
- }
-
- return Task.FromResult((string)null);
- }));
+ Add(new DynamicProviderTestScenario("Default PathPrefix", _ => { }));
+ Add(new DynamicProviderTestScenario("PathPrefix Callback",
+ options => options.DynamicProviders.PathMatchingCallback = ctx => ctx.Request.Path.StartsWithSegments("/federation/idp1", StringComparison.InvariantCulture)
+ ? Task.FromResult("idp1")
+ : Task.FromResult((string)null)));
}
}
}
diff --git a/identity-server/test/IdentityServer.IntegrationTests/TestFramework/GenericHost.cs b/identity-server/test/IdentityServer.IntegrationTests/TestFramework/GenericHost.cs
index 7806adf25..072f35ed3 100644
--- a/identity-server/test/IdentityServer.IntegrationTests/TestFramework/GenericHost.cs
+++ b/identity-server/test/IdentityServer.IntegrationTests/TestFramework/GenericHost.cs
@@ -52,7 +52,7 @@ public class GenericHost
return _baseAddress + path;
}
- public async Task InitializeAsync()
+ public async ValueTask InitializeAsync()
{
var builder = WebApplication.CreateBuilder(new WebApplicationOptions
{
diff --git a/identity-server/test/IdentityServer.IntegrationTests/TestHosts/ConfigurationIntegrationTestBase.cs b/identity-server/test/IdentityServer.IntegrationTests/TestHosts/ConfigurationIntegrationTestBase.cs
index ea7d4a987..a9b8850ae 100644
--- a/identity-server/test/IdentityServer.IntegrationTests/TestHosts/ConfigurationIntegrationTestBase.cs
+++ b/identity-server/test/IdentityServer.IntegrationTests/TestHosts/ConfigurationIntegrationTestBase.cs
@@ -15,9 +15,9 @@ public class ConfigurationIntegrationTestBase
{
var dbRoot = new InMemoryDatabaseRoot();
IdentityServerHost = new IdentityServerHost(dbRoot);
- IdentityServerHost.InitializeAsync().Wait();
+ IdentityServerHost.InitializeAsync().AsTask().Wait();
ConfigurationHost = new ConfigurationHost(dbRoot);
- ConfigurationHost.InitializeAsync().Wait();
+ ConfigurationHost.InitializeAsync().AsTask().Wait();
}
}
diff --git a/identity-server/test/IdentityServer.UnitTests/Validation/ClientConfigurationValidation.cs b/identity-server/test/IdentityServer.UnitTests/Validation/ClientConfigurationValidation.cs
index 968108833..db62bbcee 100644
--- a/identity-server/test/IdentityServer.UnitTests/Validation/ClientConfigurationValidation.cs
+++ b/identity-server/test/IdentityServer.UnitTests/Validation/ClientConfigurationValidation.cs
@@ -514,13 +514,13 @@ public class ClientConfigurationValidation
context.ErrorMessage.ShouldBe(expectedError);
}
- public static TheoryData> GrantTypesWithClientCredentialsTestData =>
- [
+ public static TheoryData> GrantTypesWithClientCredentialsTestData => new()
+ {
GrantTypes.ImplicitAndClientCredentials,
GrantTypes.CodeAndClientCredentials,
GrantTypes.HybridAndClientCredentials,
GrantTypes.ClientCredentials,
GrantTypes.ResourceOwnerPasswordAndClientCredentials
- ];
+ };
}
diff --git a/shared/Xunit.Playwright/AppHostFixture.cs b/shared/Xunit.Playwright/AppHostFixture.cs
index 8e0b3e0cb..890262393 100644
--- a/shared/Xunit.Playwright/AppHostFixture.cs
+++ b/shared/Xunit.Playwright/AppHostFixture.cs
@@ -24,7 +24,7 @@ public class AppHostFixture(IAppHostServiceRoutes routes) : IAsyncLifetim
public bool UsingAlreadyRunningInstance { get; private set; }
public string StartupLogs => _startupLogs.ToString() ?? string.Empty;
- public async Task InitializeAsync()
+ public async ValueTask InitializeAsync()
{
using var startupLogWriter = ConnectLogger(s => _startupLogs.Write(s));
@@ -103,7 +103,7 @@ public class AppHostFixture(IAppHostServiceRoutes routes) : IAsyncLifetim
}
- public async Task DisposeAsync()
+ public async ValueTask DisposeAsync()
{
if (_app != null)
{
@@ -237,7 +237,7 @@ public class AppHostFixture(IAppHostServiceRoutes routes) : IAsyncLifetim
return _app.GetEndpoint(hostName);
#else
- Skip.If(true, "When running the Host.Tests using NCrunch, you must start the Hosts.AppHost project manually. IE: dotnet run -p bff/samples/Hosts.AppHost. Or start without debugging from the UI. ");
+ Assert.Skip("When running the Host.Tests using NCrunch, you must start the Hosts.AppHost project manually. IE: dotnet run -p bff/samples/Hosts.AppHost. Or start without debugging from the UI. ");
return null!;
#endif
}
diff --git a/shared/Xunit.Playwright/Duende.Xunit.Playwright.csproj b/shared/Xunit.Playwright/Duende.Xunit.Playwright.csproj
index fe2a6dc09..b8efccbcf 100644
--- a/shared/Xunit.Playwright/Duende.Xunit.Playwright.csproj
+++ b/shared/Xunit.Playwright/Duende.Xunit.Playwright.csproj
@@ -18,13 +18,12 @@
-
+
-
-
+
-
+
diff --git a/shared/Xunit.Playwright/IntegrationTestBase.cs b/shared/Xunit.Playwright/IntegrationTestBase.cs
index 37d9a35db..b6cd258cd 100644
--- a/shared/Xunit.Playwright/IntegrationTestBase.cs
+++ b/shared/Xunit.Playwright/IntegrationTestBase.cs
@@ -1,7 +1,6 @@
// Copyright (c) Duende Software. All rights reserved.
// See LICENSE in the project root for license information.
-using Xunit.Abstractions;
namespace Duende.Xunit.Playwright;
@@ -23,7 +22,7 @@ public class IntegrationTestBase : IDisposable where THost : class
#if DEBUG_NCRUNCH
// Running in NCrunch. NCrunch cannot build the aspire project, so it needs
// to be started manually.
- Skip.If(true, "When running the Host.Tests using NCrunch, you must start the Hosts.AppHost project manually. IE: dotnet run -p bff/samples/Hosts.AppHost. Or start without debugging from the UI. ");
+ Assert.Skip("When running the Host.Tests using NCrunch, you must start the Hosts.AppHost project manually. IE: dotnet run -p bff/samples/Hosts.AppHost. Or start without debugging from the UI. ");
#endif
}
}
diff --git a/shared/Xunit.Playwright/PlaywrightTestBase.cs b/shared/Xunit.Playwright/PlaywrightTestBase.cs
index be3d3b562..7fa2eabb8 100644
--- a/shared/Xunit.Playwright/PlaywrightTestBase.cs
+++ b/shared/Xunit.Playwright/PlaywrightTestBase.cs
@@ -3,8 +3,6 @@
using System.Reflection;
using Microsoft.Playwright;
-using Microsoft.Playwright.Xunit;
-using Xunit.Abstractions;
using Xunit.Sdk;
namespace Duende.Xunit.Playwright;
@@ -12,13 +10,20 @@ namespace Duende.Xunit.Playwright;
public class Defaults
{
public static readonly PageGotoOptions PageGotoOptions = new PageGotoOptions()
- { WaitUntil = WaitUntilState.NetworkIdle };
+ {
+ WaitUntil = WaitUntilState.NetworkIdle
+ };
}
[WithTestName]
-public class PlaywrightTestBase : PageTest, IDisposable where THost : class
+public class PlaywrightTestBase : IAsyncLifetime, IDisposable where THost : class
{
private readonly IDisposable _loggingScope;
+ private IPlaywright? _playwright;
+ private IBrowser? _browser;
+
+ protected IBrowserContext Context { get; private set; } = null!;
+ protected IPage Page { get; private set; } = null!;
public PlaywrightTestBase(ITestOutputHelper output, AppHostFixture fixture)
{
@@ -35,14 +40,22 @@ public class PlaywrightTestBase : PageTest, IDisposable where THost : cla
#if DEBUG_NCRUNCH
// Running in NCrunch. NCrunch cannot build the aspire project, so it needs
// to be started manually.
- Skip.If(true, "When running the Host.Tests using NCrunch, you must start the Hosts.AppHost project manually. IE: dotnet run -p bff/samples/Hosts.AppHost. Or start without debugging from the UI. ");
+ Assert.Skip("When running the Host.Tests using NCrunch, you must start the Hosts.AppHost project manually. IE: dotnet run -p bff/samples/Hosts.AppHost. Or start without debugging from the UI. ");
#endif
}
}
- public override async Task InitializeAsync()
+ public AppHostFixture Fixture { get; }
+
+ public ITestOutputHelper Output { get; }
+
+ public virtual async ValueTask InitializeAsync()
{
- await base.InitializeAsync();
+ _playwright = await Microsoft.Playwright.Playwright.CreateAsync();
+ _browser = await _playwright.Chromium.LaunchAsync(new() { Headless = true });
+ Context = await _browser.NewContextAsync(ContextOptions());
+ Page = await Context.NewPageAsync();
+
Context.SetDefaultTimeout(10_000);
await Context.Tracing.StartAsync(new()
{
@@ -53,7 +66,7 @@ public class PlaywrightTestBase : PageTest, IDisposable where THost : cla
});
}
- public override async Task DisposeAsync()
+ public virtual async ValueTask DisposeAsync()
{
var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? Environment.CurrentDirectory;
// if path ends with /bin/{build configuration}/{dotnetversion}, then strip that from the path.
@@ -63,7 +76,6 @@ public class PlaywrightTestBase : PageTest, IDisposable where THost : cla
path = Path.GetFullPath(Path.Combine(path, "../../../"));
}
-
await Context.Tracing.StopAsync(new()
{
Path = Path.Combine(
@@ -72,10 +84,13 @@ public class PlaywrightTestBase : PageTest, IDisposable where THost : cla
$"{WithTestNameAttribute.CurrentClassName}.{WithTestNameAttribute.CurrentTestName}.zip"
)
});
- await base.DisposeAsync();
+
+ await Context.CloseAsync();
+ await _browser!.DisposeAsync();
+ _playwright!.Dispose();
}
- public override BrowserNewContextOptions ContextOptions() => new()
+ public virtual BrowserNewContextOptions ContextOptions() => new()
{
Locale = "en-US",
ColorScheme = ColorScheme.Light,
@@ -86,11 +101,6 @@ public class PlaywrightTestBase : PageTest, IDisposable where THost : cla
IgnoreHTTPSErrors = true,
};
-
- public AppHostFixture Fixture { get; }
-
- public ITestOutputHelper Output { get; }
-
public void Dispose()
{
if (!Fixture.UsingAlreadyRunningInstance)
@@ -109,19 +119,3 @@ public class PlaywrightTestBase : PageTest, IDisposable where THost : cla
public HttpClient CreateHttpClient(string clientName) => Fixture.CreateHttpClient(clientName);
}
-
-public class WithTestNameAttribute : BeforeAfterTestAttribute
-{
- public static string CurrentTestName = string.Empty;
- public static string CurrentClassName = string.Empty;
-
- public override void Before(MethodInfo methodInfo)
- {
- CurrentTestName = methodInfo.Name;
- CurrentClassName = methodInfo.DeclaringType!.Name;
- }
-
- public override void After(MethodInfo methodInfo)
- {
- }
-}
diff --git a/shared/Xunit.Playwright/Retries/RetryableFact.cs b/shared/Xunit.Playwright/Retries/RetryableFact.cs
deleted file mode 100644
index 912043db9..000000000
--- a/shared/Xunit.Playwright/Retries/RetryableFact.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (c) Duende Software. All rights reserved.
-// See LICENSE in the project root for license information.
-
-using Xunit.Sdk;
-
-namespace Duende.Xunit.Playwright.Retries;
-
-[XunitTestCaseDiscoverer(
- typeName: "Duende.Hosts.Tests.TestInfra.Retries.RetryableTestDiscoverer",
- assemblyName: "Duende.Hosts.Tests"
-)]
-public class RetryableFact : FactAttribute
-{
- public int MaxRetries { get; set; } = 5;
-}
diff --git a/shared/Xunit.Playwright/Retries/RetryableTestCase.cs b/shared/Xunit.Playwright/Retries/RetryableTestCase.cs
deleted file mode 100644
index ecac29181..000000000
--- a/shared/Xunit.Playwright/Retries/RetryableTestCase.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright (c) Duende Software. All rights reserved.
-// See LICENSE in the project root for license information.
-
-using Xunit.Abstractions;
-using Xunit.Sdk;
-
-namespace Duende.Xunit.Playwright.Retries;
-
-public class RetryableTestCase(
- IMessageSink sink,
- TestMethodDisplay display,
- TestMethodDisplayOptions methodDisplayOptions,
- ITestMethod method
-) : XunitTestCase(sink,
- display,
- methodDisplayOptions,
- method,
- testMethodArguments: null)
-{
- public override async Task RunAsync(
- IMessageSink diagnosticMessageSink,
- IMessageBus messageBus,
- object[] constructorArguments,
- ExceptionAggregator aggregator,
- CancellationTokenSource cts)
- {
- var retryCount = 0;
- var maxRetries = Method.GetCustomAttributes(typeof(RetryableFact)).FirstOrDefault()?.GetNamedArgument(nameof(RetryableFact.MaxRetries)) ?? 5;
-
- while (true)
- {
- retryCount++;
-
- var exceptionCapturingBus = new ExceptionCapturingMessageBus(messageBus);
- var summary = await base.RunAsync(
- diagnosticMessageSink,
- exceptionCapturingBus,
- constructorArguments,
- aggregator,
- cts);
-
- summary.Failed -= exceptionCapturingBus.SkippedCount;
- summary.Skipped += exceptionCapturingBus.SkippedCount;
-
- if (aggregator.HasExceptions || summary.Failed == 0 || retryCount >= maxRetries)
- {
- exceptionCapturingBus.Flush();
- return summary;
- }
-
- diagnosticMessageSink.OnMessage(new DiagnosticMessage(
- "Execution of retriable test '{0}' failed. Attempt {1} of {2}",
- DisplayName,
- retryCount,
- maxRetries
- ));
- }
- }
-
-
-}
diff --git a/shared/Xunit.Playwright/Retries/RetryableTestDiscoverer.cs b/shared/Xunit.Playwright/Retries/RetryableTestDiscoverer.cs
deleted file mode 100644
index d460ecaae..000000000
--- a/shared/Xunit.Playwright/Retries/RetryableTestDiscoverer.cs
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright (c) Duende Software. All rights reserved.
-// See LICENSE in the project root for license information.
-
-using Xunit.Abstractions;
-using Xunit.Sdk;
-
-namespace Duende.Xunit.Playwright.Retries;
-
-public class RetryableTestDiscoverer(IMessageSink messageSink) : IXunitTestCaseDiscoverer
-{
- public IEnumerable Discover(
- ITestFrameworkDiscoveryOptions discoveryOptions,
- ITestMethod testMethod,
- IAttributeInfo factAttribute)
- {
- yield return new RetryableTestCase(
- messageSink,
- discoveryOptions.MethodDisplayOrDefault(),
- discoveryOptions.MethodDisplayOptionsOrDefault(),
- testMethod
- );
- }
-}
-
-public class ExceptionCapturingMessageBus(IMessageBus inner) : IMessageBus
-{
- private readonly object _syncRoot = new();
- private readonly Queue _failedMessages = new();
- private bool _disposed = false;
-
- public bool ExceptionHasOccurred { get; private set; }
- public int SkippedCount { get; private set; }
-
- public bool QueueMessage(IMessageSinkMessage message)
- {
- if (_disposed)
- {
- throw new ObjectDisposedException(nameof(ExceptionCapturingMessageBus));
- }
-
- var skipTest = false;
-
- if (message is ITestFailed failed)
- {
- // We ignore 'skip' exceptions
- if (failed.ExceptionTypes.Contains("XUnit.SkipException", StringComparer.InvariantCultureIgnoreCase))
- {
- skipTest = true;
- }
- else
- {
- ExceptionHasOccurred = true;
- }
-
- if (skipTest)
- {
- SkippedCount++;
- return inner.QueueMessage(new TestSkipped(failed.Test, "Skipped"));
- }
- }
-
- lock (_syncRoot)
- {
- _failedMessages.Enqueue(message);
- }
-
-
-
- return true;
- }
-
- public void Flush()
- {
- lock (_syncRoot)
- {
- while (_failedMessages.Any())
- {
- inner.QueueMessage(_failedMessages.Dequeue());
- }
- }
- }
-
- public void Dispose()
- {
- if (_disposed)
- {
- return;
- }
-
- lock (_syncRoot)
- {
- if (_disposed)
- {
- return;
- }
-
- _disposed = true;
- }
-
- Flush();
- }
-}
diff --git a/shared/Xunit.Playwright/WithTestNameAttribute.cs b/shared/Xunit.Playwright/WithTestNameAttribute.cs
new file mode 100644
index 000000000..73d3c483d
--- /dev/null
+++ b/shared/Xunit.Playwright/WithTestNameAttribute.cs
@@ -0,0 +1,22 @@
+// Copyright (c) Duende Software. All rights reserved.
+// See LICENSE in the project root for license information.
+
+using System.Reflection;
+using Xunit.v3;
+
+namespace Duende.Xunit.Playwright;
+
+public class WithTestNameAttribute : Attribute, IBeforeAfterTestAttribute
+{
+ public static string CurrentTestName = string.Empty;
+ public static string CurrentClassName = string.Empty;
+
+ public void Before(MethodInfo methodInfo, IXunitTest _)
+ {
+ CurrentTestName = methodInfo.Name;
+ CurrentClassName = methodInfo.DeclaringType!.Name;
+ }
+
+ public void After(MethodInfo methodInfo, IXunitTest _)
+ { }
+}
diff --git a/src.props b/src.props
index 010b4b20f..81ab951e6 100644
--- a/src.props
+++ b/src.props
@@ -62,10 +62,6 @@
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/test.props b/test.props
index 61a33ca95..a6856335d 100644
--- a/test.props
+++ b/test.props
@@ -6,6 +6,7 @@
full
false
true
+ Exe
true
true
@@ -25,17 +26,9 @@
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
+