MartinCostello.Logging.XUnit.v3
0.5.1
dotnet add package MartinCostello.Logging.XUnit.v3 --version 0.5.1
NuGet\Install-Package MartinCostello.Logging.XUnit.v3 -Version 0.5.1
<PackageReference Include="MartinCostello.Logging.XUnit.v3" Version="0.5.1" />
paket add MartinCostello.Logging.XUnit.v3 --version 0.5.1
#r "nuget: MartinCostello.Logging.XUnit.v3, 0.5.1"
// Install MartinCostello.Logging.XUnit.v3 as a Cake Addin #addin nuget:?package=MartinCostello.Logging.XUnit.v3&version=0.5.1 // Install MartinCostello.Logging.XUnit.v3 as a Cake Tool #tool nuget:?package=MartinCostello.Logging.XUnit.v3&version=0.5.1
xunit Logging
Introduction
MartinCostello.Logging.XUnit
and MartinCostello.Logging.XUnit.v3
provide extensions to hook
into the ILogger
infrastructure to output logs from your xunit tests to the test output.
Usage
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Xunit;
using Xunit.Abstractions; // For xunit v2 - not required for xunit v3
namespace MyApp.Calculator;
public class CalculatorTests(ITestOutputHelper outputHelper)
{
[Fact]
public void Calculator_Sums_Two_Integers()
{
// Arrange
using var serviceProvider = new ServiceCollection()
.AddLogging((builder) => builder.AddXUnit(outputHelper))
.AddSingleton<Calculator>()
.BuildServiceProvider();
var calculator = services.GetRequiredService<Calculator>();
// Act
int actual = calculator.Sum(1, 2);
// Assert
Assert.AreEqual(3, actual);
}
}
public sealed class Calculator(ILogger<Calculator> logger)
{
public int Sum(int x, int y)
{
int sum = x + y;
logger.LogInformation("The sum of {x} and {y} is {sum}.", x, y, sum);
return sum;
}
}
Feedback
Any feedback or issues can be added to the issues for this project in GitHub.
License
This project is licensed under the Apache 2.0 license.
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 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Framework | net472 is compatible. net48 was computed. net481 was computed. |
-
.NETFramework 4.7.2
- Microsoft.Extensions.Logging (>= 8.0.1)
- xunit.v3.extensibility.core (>= 1.0.0)
-
net8.0
- Microsoft.Extensions.Logging (>= 8.0.1)
- xunit.v3.extensibility.core (>= 1.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on MartinCostello.Logging.XUnit.v3:
Package | Downloads |
---|---|
Xunit.DependencyInjection.Logging
Support Microsoft.Extensions.Logging to ITestOutputHelper. public void Configure(IServiceProvider provider) { XunitTestOutputLoggerProvider.Register(provider); } |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on MartinCostello.Logging.XUnit.v3:
Repository | Stars |
---|---|
martincostello/dotnet-minimal-api-integration-testing
An example of integration testing ASP.NET Core Minimal hosting and APIs
|
|
martincostello/sqllocaldb
SQL LocalDB Wrapper is a .NET library providing interop with the Microsoft SQL Server LocalDB Instance API
|
See https://github.com/martincostello/xunit-logging/releases for details.