Created
February 26, 2016 15:04
-
-
Save martincostello/d1130f542106ce4d4538 to your computer and use it in GitHub Desktop.
BenchmarkDotNet Logger for Xunit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace MartinCostello | |
{ | |
using BenchmarkDotNet.Loggers; | |
using Xunit.Abstractions; | |
/// <summary> | |
/// A class that writes output to the test output for Xunit. This class cannot be inherited. | |
/// </summary> | |
public sealed class XunitTestOutputLogger : ILogger | |
{ | |
/// <summary> | |
/// The <see cref="ITestOutputHelper"/> in use. This field is read-only. | |
/// </summary> | |
private readonly ITestOutputHelper _helper; | |
/// <summary> | |
/// Initializes a new instance of the <see cref="XunitTestOutputLogger"/> class. | |
/// </summary> | |
/// <param name="helper">The <see cref="ITestOutputHelper"/> to use.</param> | |
public XunitTestOutputLogger(ITestOutputHelper helper) | |
{ | |
_helper = helper; | |
} | |
/// <inheritdoc /> | |
public void Write(LogKind logKind, string format, params object[] args) | |
{ | |
_helper.WriteLine(format, args); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Obviously requires you to have BenchmarkDotNet and Xunit first: