Codebelt.Extensions.Xunit.Hosting.AspNetCore
9.0.0-preview.8
See the version list below for details.
dotnet add package Codebelt.Extensions.Xunit.Hosting.AspNetCore --version 9.0.0-preview.8
NuGet\Install-Package Codebelt.Extensions.Xunit.Hosting.AspNetCore -Version 9.0.0-preview.8
<PackageReference Include="Codebelt.Extensions.Xunit.Hosting.AspNetCore" Version="9.0.0-preview.8" />
paket add Codebelt.Extensions.Xunit.Hosting.AspNetCore --version 9.0.0-preview.8
#r "nuget: Codebelt.Extensions.Xunit.Hosting.AspNetCore, 9.0.0-preview.8"
// Install Codebelt.Extensions.Xunit.Hosting.AspNetCore as a Cake Addin #addin nuget:?package=Codebelt.Extensions.Xunit.Hosting.AspNetCore&version=9.0.0-preview.8&prerelease // Install Codebelt.Extensions.Xunit.Hosting.AspNetCore as a Cake Tool #tool nuget:?package=Codebelt.Extensions.Xunit.Hosting.AspNetCore&version=9.0.0-preview.8&prerelease
About
An open-source project (MIT license) that targets and complements the xUnit.net test platform. It provides a uniform and convenient way of doing unit test for all project types in .NET.
Perhaps even more convenient than what WebApplicationFactory has to offer?
It is, by heart, free, flexible and built to extend and boost your agile codebelt.
Codebelt.Extensions.Xunit.Hosting.AspNetCore for .NET
The Codebelt.Extensions.Xunit.Hosting.AspNetCore
namespace contains types that provides a uniform way of doing unit testing that depends on ASP.NET Core and used in conjunction with Microsoft Dependency Injection. The namespace relates to the Microsoft.AspNetCore.TestHost
namespace.
More documentation available at our documentation site:
- Codebelt.Extensions.Xunit.Hosting.AspNetCore 🔗
- Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http 🔗
- Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features 🔗
Related Packages
- Codebelt.Extensions.Xunit 📦
- Codebelt.Extensions.Xunit.App 🏭
- Codebelt.Extensions.Xunit.Hosting 📦
- Codebelt.Extensions.Xunit.Hosting.AspNetCore 📦
CSharp Example
Source: ServerTimingMiddlewareTest.cs
[Fact]
public async Task InvokeAsync_ShouldMimicSimpleAspNetProject()
{
using var response = await WebHostTestFactory.RunAsync(
services =>
{
services.AddServerTiming(o => o.SuppressHeaderPredicate = _ => false);
}
, app =>
{
app.UseServerTiming();
app.Use(async (context, next) =>
{
var sw = Stopwatch.StartNew();
context.Response.OnStarting(() =>
{
sw.Stop();
context.RequestServices.GetRequiredService<IServerTiming>().AddServerTiming("use-middleware", sw.Elapsed);
return Task.CompletedTask;
});
await next(context).ConfigureAwait(false);
});
app.Run(context =>
{
Thread.Sleep(400);
return context.Response.WriteAsync("Hello World!");
});
}).ConfigureAwait(false);
Assert.StartsWith("use-middleware;dur=", response.Headers.Single(kvp => kvp.Key == ServerTiming.HeaderName).Value.FirstOrDefault());
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. |
-
net8.0
- Codebelt.Extensions.Xunit.Hosting (>= 9.0.0-preview.8)
- Microsoft.AspNetCore.TestHost (>= 8.0.8)
-
net9.0
- Codebelt.Extensions.Xunit.Hosting (>= 9.0.0-preview.8)
- Microsoft.AspNetCore.TestHost (>= 9.0.0-rc.1.24452.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Codebelt.Extensions.Xunit.Hosting.AspNetCore:
Package | Downloads |
---|---|
Codebelt.Extensions.Xunit.App
Provides a convenient set of default API additions for building .NET test projects based on xUnit. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
9.0.0 | 974 | 11/13/2024 |
9.0.0-rc.1 | 504 | 11/11/2024 |
9.0.0-preview.11 | 118 | 10/26/2024 |
9.0.0-preview.10 | 228 | 10/9/2024 |
9.0.0-preview.9 | 288 | 10/6/2024 |
9.0.0-preview.8 | 189 | 10/4/2024 |
9.0.0-preview.7 | 54 | 10/3/2024 |
9.0.0-preview.6 | 131 | 10/1/2024 |
9.0.0-preview.5 | 50 | 9/30/2024 |
9.0.0-preview.4 | 390 | 9/25/2024 |
9.0.0-preview.3 | 49 | 9/23/2024 |
9.0.0-preview.2 | 127 | 9/17/2024 |
9.0.0-preview.1 | 75 | 9/15/2024 |
8.4.1 | 416 | 9/16/2024 |
8.4.0 | 134 | 9/15/2024 |
Version 9.0.0
Availability: .NET 9 and .NET 8
# ALM
- CHANGED Dependencies to latest and greatest with respect to TFMs
- REMOVED Support for TFM .NET 6 (LTS)
# Bug Fixes
- FIXED AspNetCoreHostFixture class in the Codebelt.Extensions.Xunit.Hosting.AspNetCore namespace to preserve ExecutionContext and AsyncLocal{T} values from the client to the server (vital for ITestOutputHelperAccessor combined with xUnit test logging when using HttpClient)
Version 8.4.0
Availability: .NET 8 and .NET 6
# ALM
- CHANGED Dependencies to latest and greatest with respect to TFMs
# Breaking Changes
- REMOVED IMiddlewareTest interface from the Codebelt.Extensions.Xunit.Hosting.AspNetCore namespace
- REMOVED MiddlewareTestFactory static class from the Codebelt.Extensions.Xunit.Hosting.AspNetCore namespace
- RENAMED Run method on the WebHostTestFactory class in the Codebelt.Extensions.Xunit.Hosting.AspNetCore to RunAsync
- RENAMED RunWithHostBuilderContext method on the WebHostTestFactory class in the Codebelt.Extensions.Xunit.Hosting.AspNetCore to RunWithHostBuilderContextAsync
# Improvements
- CHANGED AspNetCoreHostFixture class in the Codebelt.Extensions.Xunit.Hosting.AspNetCore namespace to use same hostbuilder validation as introduced with the forthcoming .NET 9
# New Features
- ADDED HttpClientExtensions class in the Codebelt.Extensions.Xunit.Hosting.AspNetCore namespace that consist of one extension method for the HttpClient class: ToHttpResponseMessageAsync
Version 8.3.2
Availability: .NET 8 and .NET 6
# ALM
- REMOVED Support for TFM .NET 7 (STS)
- CHANGED Dependencies to latest and greatest with respect to TFMs
Version 8.3.1
Availability: .NET 8, .NET 7 and .NET 6
# ALM
- CHANGED Dependencies to latest and greatest with respect to TFMs
# Improvements
- ADDED IWebHostTest interface in the Codebelt.Extensions.Xunit.Hosting.AspNetCore namespace that represents the members needed for ASP.NET Core (including but not limited to MVC, Razor and related) testing
- ADDED WebHostTestFactory class in the Codebelt.Extensions.Xunit.Hosting.AspNetCore namespace that provides a set of static methods for ASP.NET Core (including, but not limited to MVC, Razor and related) unit testing
- DEPRECATED IMiddlewareTest interface in the Codebelt.Extensions.Xunit.Hosting.AspNetCore namespace; use the consolidated IWebHostTest instead
- DEPRECATED MiddlewareTestFactory class in the Codebelt.Extensions.Xunit.Hosting.AspNetCore namespace; use the consolidated WebHostTestFactory instead
Version 8.3.0
Availability: .NET 8, .NET 7 and .NET 6
# ALM
- CHANGED Dependencies to latest and greatest with respect to TFMs
Version 8.2.0
Availability: .NET 8, .NET 7 and .NET 6
# ALM
- CHANGED Dependencies to latest and greatest with respect to TFMs
Version: 8.1.0
Availability: .NET 8, .NET 7 and .NET 6
# ALM
- CHANGED Dependencies to latest and greatest with respect to TFMs
Version: 8.0.1
Availability: .NET 8, .NET 7 and .NET 6
# ALM
- CHANGED Dependencies to latest and greatest with respect to TFMs
Version: 8.0.0
Availability: .NET 8, .NET 7 and .NET 6
# ALM
- ADDED TFM for net8.0
- REMOVED TFM for netstandard2.0
- CHANGED Dependencies to latest and greatest with respect to TFMs
# Breaking Changes
- CHANGED MiddlewareTestFactory class in the Codebelt.Extensions.Xunit.Hosting.AspNetCore namespace received a long overdue change of signature from Action{IApplicationBuilder} pipelineSetup, Action{IServiceCollection} serviceSetup --> Action{IServiceCollection} serviceSetup, Action{IApplicationBuilder} pipelineSetup as this is more logical, intuitive and in consistency with GenericHostTestFactory