MartinCostello.Logging.XUnit.v3
0.5.1
.NET 8.0
This package targets .NET 8.0. The package is compatible with this framework or higher.
.NET Framework 4.7.2
This package targets .NET Framework 4.7.2. The package is compatible with this framework or higher.
dotnet add package MartinCostello.Logging.XUnit.v3 --version 0.5.1
NuGet\Install-Package MartinCostello.Logging.XUnit.v3 -Version 0.5.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MartinCostello.Logging.XUnit.v3" Version="0.5.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MartinCostello.Logging.XUnit.v3 --version 0.5.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MartinCostello.Logging.XUnit.v3, 0.5.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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. |
.NET Framework | net472 is compatible. net48 was computed. net481 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.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
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
See https://github.com/martincostello/xunit-logging/releases for details.