All Projects → martincostello → Xunit Logging

martincostello / Xunit Logging

Licence: apache-2.0
Logging extensions for xunit

Projects that are alternatives of or similar to Xunit Logging

logging
Generic file logger for .NET Core (FileLoggerProvider) with minimal dependencies
Stars: ✭ 109 (+57.97%)
Mutual labels:  logging, dotnet-core
Easy.logger
A modern, high performance cross platform wrapper for Log4Net.
Stars: ✭ 118 (+71.01%)
Mutual labels:  logging, dotnet-core
Serilog.exceptions
Log exception details and custom properties that are not output in Exception.ToString().
Stars: ✭ 282 (+308.7%)
Mutual labels:  logging, dotnet-core
Dotnetcore
.NET 5 Nuget Packages.
Stars: ✭ 146 (+111.59%)
Mutual labels:  logging, dotnet-core
Pioneer Console Boilerplate
Dependency injection, logging and configuration in a .NET Core console application.
Stars: ✭ 60 (-13.04%)
Mutual labels:  logging, dotnet-core
Terraform Modules
Reusable Terraform modules
Stars: ✭ 63 (-8.7%)
Mutual labels:  logging
Logging Log4j2
Apache Log4j 2 is an upgrade to Log4j that provides significant improvements over its predecessor, Log4j 1.x, and provides many of the improvements available in Logback while fixing some inherent problems in Logback's architecture.
Stars: ✭ 1,133 (+1542.03%)
Mutual labels:  logging
Node Draftlog
📜 Create updatable log lines into the terminal, and give life to your logs!
Stars: ✭ 1,117 (+1518.84%)
Mutual labels:  logging
Logvac
Simple, lightweight, api-driven log aggregation service with realtime push capabilities and historical persistence.
Stars: ✭ 61 (-11.59%)
Mutual labels:  logging
Elf
The .NET 5 link forward service runs on Microsoft Azure
Stars: ✭ 68 (-1.45%)
Mutual labels:  dotnet-core
Ring Logger
Log ring requests & responses using your favorite logging backend
Stars: ✭ 66 (-4.35%)
Mutual labels:  logging
Waypoint
Opinionated solution template for building F# OSS libraries and tools.
Stars: ✭ 65 (-5.8%)
Mutual labels:  dotnet-core
Class Logger
Boilerplate-free decorator-based class logging
Stars: ✭ 64 (-7.25%)
Mutual labels:  logging
Litter
Litter is a pretty printer library for Go data structures to aid in debugging and testing.
Stars: ✭ 1,137 (+1547.83%)
Mutual labels:  logging
Angle Grinder
Slice and dice logs on the command line
Stars: ✭ 1,118 (+1520.29%)
Mutual labels:  logging
Poke
A powerful reflection module for powershell.
Stars: ✭ 66 (-4.35%)
Mutual labels:  dotnet-core
Icanpay.donet
统一支付网关。支持NET46和NETSTANDARD2_0。支持支付宝,微信,银联支付渠道通过Web,App,Wap,QRCode方式支付。简化订单的创建、查询、退款跟接收网关返回的支付通知等功能
Stars: ✭ 62 (-10.14%)
Mutual labels:  dotnet-core
Stl.fusion.samples
A collection of samples for Fusion library: https://github.com/servicetitan/Stl.Fusion
Stars: ✭ 65 (-5.8%)
Mutual labels:  dotnet-core
Drinkandgo
A simple eCommerce App build on top of Asp.Net Core MVC framework.
Stars: ✭ 65 (-5.8%)
Mutual labels:  dotnet-core
Skater .net Obfuscator
Skater .NET Obfuscator is an obfuscation tool for .NET code protection. It implements all known software protection techniques and obfuscation algorithms.
Stars: ✭ 64 (-7.25%)
Mutual labels:  dotnet-core

xunit Logging

NuGet

Build status

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

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;
        }
    }
}

See below for links to more examples:

  1. Unit tests
  2. Integration tests for an ASP.NET Core HTTP application

Feedback

Any feedback or issues can be added to the issues for this project in GitHub.

Repository

The repository is hosted in GitHub: https://github.com/martincostello/xunit-logging.git

License

This project is licensed under the Apache 2.0 license.

Building and Testing

Compiling the library yourself requires Git and the .NET SDK to be installed (version 5.0.100 or later).

To build and test the library locally from a terminal/command-line, run one of the following set of commands:

git clone https://github.com/martincostello/xunit-logging.git
cd xunit-logging
./build.ps1
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].