MartinCostello.Logging.XUnit 0.5.1

dotnet add package MartinCostello.Logging.XUnit --version 0.5.1                
NuGet\Install-Package MartinCostello.Logging.XUnit -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" 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 --version 0.5.1                
#r "nuget: MartinCostello.Logging.XUnit, 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 as a Cake Addin
#addin nuget:?package=MartinCostello.Logging.XUnit&version=0.5.1

// Install MartinCostello.Logging.XUnit as a Cake Tool
#tool nuget:?package=MartinCostello.Logging.XUnit&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 Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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 Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (14)

Showing the top 5 NuGet packages that depend on MartinCostello.Logging.XUnit:

Package Downloads
Xunit.DependencyInjection.Logging

Support Microsoft.Extensions.Logging to ITestOutputHelper. public void Configure(IServiceProvider provider) { XunitTestOutputLoggerProvider.Register(provider); }

SPG.Framework.IntegrationTest

Package Description

Sekiban.Testing

Sekiban - Event Sourcing Framework Testing

AElf.ContractTestKit

Contract testing kit.

AElf.ContractTestBase

Contract test base.

GitHub repositories (33)

Showing the top 5 popular GitHub repositories that depend on MartinCostello.Logging.XUnit:

Repository Stars
FastEndpoints/FastEndpoints
A light-weight REST API development framework for ASP.NET 6 and newer.
openiddict/openiddict-core
Flexible and versatile OAuth 2.0/OpenID Connect stack for .NET
aspnet-contrib/AspNet.Security.OAuth.Providers
OAuth 2.0 social authentication providers for ASP.NET Core
CarterCommunity/Carter
Carter is framework that is a thin layer of extension methods and functionality over ASP.NET Core allowing code to be more explicit and most importantly more enjoyable.
AElfProject/AElf
An AI-enhanced cloud-native layer-1 blockchain network. 
Version Downloads Last updated
0.5.1 2 12/26/2024
0.5.0 2,335 12/20/2024
0.4.0 694,513 6/1/2024
0.3.0 3,638,032 5/22/2022
0.2.1 27,081 5/15/2022
0.2.0 730,333 10/3/2021
0.1.2 233,355 7/12/2021
0.1.1 277,644 3/26/2021
0.1.0 1,191,196 9/30/2018
0.1.0-beta1 802 9/26/2018
0.1.0-alpha4 2,660 8/20/2018
0.1.0-alpha3 756 8/19/2018
0.1.0-alpha2 738 8/19/2018
0.1.0-alpha1 747 8/19/2018