Skip to content

Releases: martincostello/xunit-logging

v0.4.0

01 Jun 11:49
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v0.3.0...v0.4.0

v0.3.0

22 May 18:06
c522f21
Compare
Choose a tag to compare

Added

  • Support custom timestamp format in log messages (#311, #313)

Contributors

Full Changelog: v0.2.1...v0.3.0

v0.2.1

15 May 08:17
4c2b65c
Compare
Choose a tag to compare

Added

Contributors

Full Changelog: v0.2.0...v0.2.1

MartinCostello.Logging.XUnit v0.2.0

03 Oct 15:10
2e1613a
Compare
Choose a tag to compare

MartinCostello.Logging.XUnit v0.2.0

NuGet

Changed

  • Add support for IMessageSink (#246) Thanks @0xced!

Installation

To install the library from NuGet using the .NET SDK run:

dotnet add package MartinCostello.Logging.XUnit --version 0.2.0

Contributors

MartinCostello.Logging.XUnit v0.1.2

12 Jul 17:40
d0cf3ab
Compare
Choose a tag to compare

MartinCostello.Logging.XUnit v0.1.2

NuGet

Changed

Installation

To install the library from NuGet using the .NET SDK run:

dotnet add package MartinCostello.Logging.XUnit --version 0.1.2

Contributors

MartinCostello.Logging.XUnit v0.1.1

26 Mar 15:24
0e85efb
Compare
Choose a tag to compare

MartinCostello.Logging.XUnit v0.1.1

NuGet

Changed

  • Detect logging of IEnumerable<KeyValuePair<string, object>> scopes. (#214, #215) Thanks @gkinsman!
  • Update to latest recommended NuGet package publishing standards (snpkg symbols, deterministic builds etc.).
  • Update samples to latest recommended usage patterns and .NET 5.0.

Installation

To install the library from NuGet using the .NET SDK run:

dotnet add package MartinCostello.Logging.XUnit --version 0.1.1

Contributors

MartinCostello.Logging.XUnit v0.1.0

30 Sep 16:47
bd0a759
Compare
Choose a tag to compare

MartinCostello.Logging.XUnit v0.1.0

NuGet

Introduction

MartinCostello.Logging.XUnit provides extensions to hook into the ILogger infrastructure to output logs from your xunit tests to the test output.

Installation

To install the library from NuGet using the .NET SDK run:

dotnet add package MartinCostello.Logging.XUnit --version 0.1.0

Usage

using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Xunit;
using Xunit.Abstractions;

namespace MyApp.Calculator
{
    public class CalculatorTests
    {
        public CalculatorTests(ITestOutputHelper outputHelper)
        {
            OutputHelper = outputHelper;
        }

        private ITestOutputHelper OutputHelper { get; }

        [Fact]
        public void Calculator_Sums_Two_Integers()
        {
            // Arrange
            var services = new ServiceCollection()
                .AddLogging((builder) => builder.AddXUnit(OutputHelper))
                .AddSingleton<Calculator>();

            var calculator = services
                .BuildServiceProvider()
                .GetRequiredService<Calculator>();

            // Act
            int actual = calculator.Sum(1, 2);

            // Assert
            Assert.AreEqual(3, actual);
        }
    }

    public sealed class Calculator
    {
        private readonly ILogger _logger;

        public Calculator(ILogger<Calculator> logger)
        {
            _logger = 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;
        }
    }
}

MartinCostello.Logging.XUnit v0.1.0-beta1

26 Sep 10:10
cb790fe
Compare
Choose a tag to compare

MartinCostello.Logging.XUnit v0.1.0-beta1

Fixed

  • Handle exception trying to log if the ITestOutputHelper has not yet been disassociated with the application after a test ends. (#12)

Infrastructure

  • Added CI build for Azure Pipelines. (#11)
  • Updated sample application to ASP.NET Core 2.1.4. (#11)

MartinCostello.Logging.XUnit v0.1.0-alpha4

20 Aug 17:58
2f10fca
Compare
Choose a tag to compare

MartinCostello.Logging.XUnit v0.1.0-alpha4

Added

  • Added new ITestOutputHelperAccessor interface (and infrastructure to use it) to allow long-lived test fixtures, such as test collection fixtures, to hook in a ITestOutputHelper on a per-test basis. (#7, #8)

MartinCostello.Logging.XUnit v0.1.0-alpha3

19 Aug 20:53
b59a087
Compare
Choose a tag to compare

MartinCostello.Logging.XUnit v0.1.0-alpha3

Added

  • Add ToLoggerFactory() and ToLogger<T>() extension methods for ITestOutputHelper. (#4, #6)