diff --git a/.github/workflows/pipelines.yml b/.github/workflows/pipelines.yml index 94e3e62..617ebad 100644 --- a/.github/workflows/pipelines.yml +++ b/.github/workflows/pipelines.yml @@ -27,7 +27,7 @@ jobs: strategy: matrix: configuration: [Debug, Release] - uses: codebeltnet/jobs-dotnet-build/.github/workflows/default.yml@v1 + uses: codebeltnet/jobs-dotnet-build/.github/workflows/default.yml@v2 with: configuration: ${{ matrix.configuration }} strong-name-key-filename: xunit.snk @@ -41,10 +41,9 @@ jobs: strategy: matrix: configuration: [Debug, Release] - uses: codebeltnet/jobs-dotnet-pack/.github/workflows/default.yml@v1 + uses: codebeltnet/jobs-dotnet-pack/.github/workflows/default.yml@v2 with: configuration: ${{ matrix.configuration }} - upload-packed-artifact: true version: ${{ needs.build.outputs.version }} test: @@ -55,7 +54,7 @@ jobs: matrix: os: [ubuntu-24.04, windows-2022] configuration: [Debug, Release] - uses: codebeltnet/jobs-dotnet-test/.github/workflows/default.yml@v1 + uses: codebeltnet/jobs-dotnet-test/.github/workflows/default.yml@v2 with: configuration: ${{ matrix.configuration }} runs-on: ${{ matrix.os }} @@ -90,7 +89,7 @@ jobs: if: github.event_name != 'pull_request' name: call-nuget needs: [build, pack, test, sonarcloud, codecov, codeql] - uses: codebeltnet/jobs-nuget-push/.github/workflows/default.yml@v1 + uses: codebeltnet/jobs-nuget-push/.github/workflows/default.yml@v2 with: version: ${{ needs.build.outputs.version }} environment: Production diff --git a/.nuget/Codebelt.Extensions.Xunit.App/PackageReleaseNotes.txt b/.nuget/Codebelt.Extensions.Xunit.App/PackageReleaseNotes.txt index 40ab0d9..58e292f 100644 --- a/.nuget/Codebelt.Extensions.Xunit.App/PackageReleaseNotes.txt +++ b/.nuget/Codebelt.Extensions.Xunit.App/PackageReleaseNotes.txt @@ -1,4 +1,10 @@ -Version 10.0.1 +Version 10.0.2 +Availability: .NET 9 and .NET 8 +  +# ALM +- CHANGED Dependencies have been upgraded to the latest compatible versions for all supported target frameworks (TFMs) +  +Version 10.0.1 Availability: .NET 9 and .NET 8   # ALM diff --git a/.nuget/Codebelt.Extensions.Xunit.Hosting.AspNetCore/PackageReleaseNotes.txt b/.nuget/Codebelt.Extensions.Xunit.Hosting.AspNetCore/PackageReleaseNotes.txt index f351c0d..8778d66 100644 --- a/.nuget/Codebelt.Extensions.Xunit.Hosting.AspNetCore/PackageReleaseNotes.txt +++ b/.nuget/Codebelt.Extensions.Xunit.Hosting.AspNetCore/PackageReleaseNotes.txt @@ -1,4 +1,16 @@ -Version 10.0.1 +Version 10.0.2 +Availability: .NET 9 and .NET 8 +  +# ALM +- CHANGED Dependencies have been upgraded to the latest compatible versions for all supported target frameworks (TFMs) +  +# Bug Fixes +- FIXED ManagedWebHostFixture class in the Codebelt.Extensions.Xunit.Hosting.AspNetCore namespace to exit ConfigureHost method if the fixture is not in a valid state (e.g., configuration delegate properties are null) +  +# Improvements +- CHANGED HasValidState method on the WebHostFixtureExtensions class in the Codebelt.Extensions.Xunit.Hosting.AspNetCore namespace to exclude check of Application property +  +Version 10.0.1 Availability: .NET 9 and .NET 8   # ALM diff --git a/.nuget/Codebelt.Extensions.Xunit.Hosting/PackageReleaseNotes.txt b/.nuget/Codebelt.Extensions.Xunit.Hosting/PackageReleaseNotes.txt index 80c6acd..950a73d 100644 --- a/.nuget/Codebelt.Extensions.Xunit.Hosting/PackageReleaseNotes.txt +++ b/.nuget/Codebelt.Extensions.Xunit.Hosting/PackageReleaseNotes.txt @@ -1,4 +1,17 @@ -Version 10.0.1 +Version 10.0.2 +Availability: .NET 9, .NET 8 and .NET Standard 2.0 +  +# ALM +- CHANGED Dependencies have been upgraded to the latest compatible versions for all supported target frameworks (TFMs) +  +# Bug Fixes +- FIXED ManagedHostFixture class in the Codebelt.Extensions.Xunit.Hosting namespace to exit ConfigureHost method if the fixture is not in a valid state (e.g., configuration delegate properties are null) +  +# Improvements +- CHANGED HasValidState method on the GenericHostFixtureExtensions class in the Codebelt.Extensions.Xunit.Hosting namespace to exclude check of Host property +- CHANGED AddXunitTestLogging method on the ServiceCollectionExtensions class in the Codebelt.Extensions.Xunit.Hosting namespace to be forgiving when no active test is present (relates to https://github.com/xunit/xunit/issues/2377) +  +Version 10.0.1 Availability: .NET 9, .NET 8 and .NET Standard 2.0   # ALM diff --git a/.nuget/Codebelt.Extensions.Xunit/PackageReleaseNotes.txt b/.nuget/Codebelt.Extensions.Xunit/PackageReleaseNotes.txt index bbdf557..537b5ab 100644 --- a/.nuget/Codebelt.Extensions.Xunit/PackageReleaseNotes.txt +++ b/.nuget/Codebelt.Extensions.Xunit/PackageReleaseNotes.txt @@ -1,4 +1,10 @@ -Version 10.0.1 +Version 10.0.2 +Availability: .NET 9 and .NET 8 +  +# ALM +- CHANGED Dependencies have been upgraded to the latest compatible versions for all supported target frameworks (TFMs) +  +Version 10.0.1 Availability: .NET 9 and .NET 8   # ALM diff --git a/CHANGELOG.md b/CHANGELOG.md index c12df03..1217af5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,21 @@ For more details, please refer to `PackageReleaseNotes.txt` on a per assembly ba > [!NOTE] > Changelog entries prior to version 8.4.0 was migrated from previous versions of Cuemon.Extensions.Xunit, Cuemon.Extensions.Xunit.Hosting, and Cuemon.Extensions.Xunit.Hosting.AspNetCore. +## [10.0.2] - 2025-06-01 + +This is a minor update that addresses some non-critical issues and improves the overall developer experience of the package. + +### Changed + +- HasValidState method on the GenericHostFixtureExtensions class in the Codebelt.Extensions.Xunit.Hosting namespace to exclude check of Host property +- AddXunitTestLogging method on the ServiceCollectionExtensions class in the Codebelt.Extensions.Xunit.Hosting namespace to be forgiving when no active test is present (relates to https://github.com/xunit/xunit/issues/2377) + - You should use the ITestOutputHelperAccessor capability provided by AddXunitTestLoggingOutputHelperAccessor instead to set the ITestOutputHelper instance in your tests (e.g., in your constructor call `fixture.Host.Services.GetRequiredService().TestOutput = output;`) + +### Fixed + +- ManagedHostFixture class in the Codebelt.Extensions.Xunit.Hosting namespace to exit ConfigureHost method if the fixture is not in a valid state (e.g., configuration delegate properties are null) +- ManagedWebHostFixture class in the Codebelt.Extensions.Xunit.Hosting.AspNetCore namespace to exit ConfigureHost method if the fixture is not in a valid state (e.g., configuration delegate properties are null) + ## [10.0.1] - 2025-05-24 This is a service update that focuses on package dependencies. diff --git a/Directory.Packages.props b/Directory.Packages.props index 97da020..abaf712 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -8,7 +8,7 @@ - + diff --git a/src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/ManagedWebHostFixture.cs b/src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/ManagedWebHostFixture.cs index 0c9f0cb..af5ce7c 100644 --- a/src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/ManagedWebHostFixture.cs +++ b/src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/ManagedWebHostFixture.cs @@ -40,6 +40,7 @@ public override void ConfigureHost(Test hostTest) { ArgumentNullException.ThrowIfNull(hostTest); if (!HasTypes(hostTest.GetType(), typeof(WebHostTest<>))) { throw new ArgumentOutOfRangeException(nameof(hostTest), typeof(WebHostTest<>), $"{nameof(hostTest)} is not assignable from WebHostTest."); } + if (!this.HasValidState()) { return; } // had to include this due to dual-call this method (one uncontrolled from xUnit library reflection magic; second controlled from this library) var hb = new HostBuilder() .ConfigureWebHost(webBuilder => @@ -73,7 +74,7 @@ public override void ConfigureHost(Test hostTest) }) .Configure(app => { - ConfigureApplicationCallback(app); + ConfigureApplicationCallback.Invoke(app); Application = app; } ) diff --git a/src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/WebHostFixtureExtensions.cs b/src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/WebHostFixtureExtensions.cs index 4f03f0a..246aa40 100644 --- a/src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/WebHostFixtureExtensions.cs +++ b/src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/WebHostFixtureExtensions.cs @@ -12,13 +12,12 @@ public static class WebHostFixtureExtensions /// true if the specified has a valid state; otherwise, false. /// /// A valid state is defined as having non-null values for the following properties: - /// , , , - /// and . + /// , and . /// public static bool HasValidState(this IWebHostFixture hostFixture) { var hasValidState = ((IGenericHostFixture)hostFixture).HasValidState(); - return hasValidState && hostFixture.ConfigureApplicationCallback != null && hostFixture.Application != null; + return hasValidState && hostFixture.ConfigureApplicationCallback != null; } } } diff --git a/src/Codebelt.Extensions.Xunit.Hosting/GenericHostFixtureExtensions.cs b/src/Codebelt.Extensions.Xunit.Hosting/GenericHostFixtureExtensions.cs index 0a11ffb..373f8ef 100644 --- a/src/Codebelt.Extensions.Xunit.Hosting/GenericHostFixtureExtensions.cs +++ b/src/Codebelt.Extensions.Xunit.Hosting/GenericHostFixtureExtensions.cs @@ -12,12 +12,11 @@ public static class GenericHostFixtureExtensions /// true if the specified has a valid state; otherwise, false. /// /// A valid state is defined as having non-null values for the following properties: - /// , and . + /// and . /// public static bool HasValidState(this IGenericHostFixture hostFixture) { return hostFixture.ConfigureServicesCallback != null && - hostFixture.Host != null && hostFixture.ConfigureHostCallback != null; } } diff --git a/src/Codebelt.Extensions.Xunit.Hosting/ManagedHostFixture.cs b/src/Codebelt.Extensions.Xunit.Hosting/ManagedHostFixture.cs index 435293a..7a593c7 100644 --- a/src/Codebelt.Extensions.Xunit.Hosting/ManagedHostFixture.cs +++ b/src/Codebelt.Extensions.Xunit.Hosting/ManagedHostFixture.cs @@ -37,6 +37,7 @@ public virtual void ConfigureHost(Test hostTest) { if (hostTest == null) { throw new ArgumentNullException(nameof(hostTest)); } if (!HasTypes(hostTest.GetType(), typeof(HostTest<>))) { throw new ArgumentOutOfRangeException(nameof(hostTest), typeof(HostTest<>), $"{nameof(hostTest)} is not assignable from HostTest."); } + if (!this.HasValidState()) { return; } // had to include this due to dual-call this method (one uncontrolled from xUnit library reflection magic; second controlled from this library) var hb = new HostBuilder() .UseContentRoot(Directory.GetCurrentDirectory()) diff --git a/src/Codebelt.Extensions.Xunit.Hosting/XunitTestLogger.cs b/src/Codebelt.Extensions.Xunit.Hosting/XunitTestLogger.cs index 66d7e5c..8410b19 100644 --- a/src/Codebelt.Extensions.Xunit.Hosting/XunitTestLogger.cs +++ b/src/Codebelt.Extensions.Xunit.Hosting/XunitTestLogger.cs @@ -41,7 +41,14 @@ public void Log(LogLevel logLevel, EventId eventId, TState state, Except } else { - _output?.WriteLine(message); + try + { + _output?.WriteLine(message); + } + catch (InvalidOperationException) + { + // can happen when there is no currently active test (e.g., you should use the ITestOutputHelperAccessor capability) + } } } diff --git a/testenvironments.json b/testenvironments.json index 1270327..0214cf5 100644 --- a/testenvironments.json +++ b/testenvironments.json @@ -9,7 +9,7 @@ { "name": "Docker-Ubuntu", "type": "docker", - "dockerImage": "gimlichael/ubuntu-testrunner:mono-net8.0.409-9.0.300" + "dockerImage": "gimlichael/ubuntu-testrunner:net8.0.409-9.0.300" } ] }