Enabling Debug logging in a flaky test
This commit is contained in:
parent
e8ad3b4160
commit
4bacbfeb05
|
|
@ -16,6 +16,7 @@ using Xunit;
|
||||||
|
|
||||||
using ClientConnection = Microsoft.AspNetCore.Sockets.Client.Connection;
|
using ClientConnection = Microsoft.AspNetCore.Sockets.Client.Connection;
|
||||||
using Microsoft.AspNetCore.SignalR.Tests.Common;
|
using Microsoft.AspNetCore.SignalR.Tests.Common;
|
||||||
|
using Xunit.Abstractions;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.SignalR.Tests
|
namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
{
|
{
|
||||||
|
|
@ -28,15 +29,19 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
[Collection(EndToEndTestsCollection.Name)]
|
[Collection(EndToEndTestsCollection.Name)]
|
||||||
public class EndToEndTests
|
public class EndToEndTests
|
||||||
{
|
{
|
||||||
|
private readonly ITestOutputHelper _output;
|
||||||
|
|
||||||
private readonly ServerFixture _serverFixture;
|
private readonly ServerFixture _serverFixture;
|
||||||
|
|
||||||
public EndToEndTests(ServerFixture serverFixture)
|
public EndToEndTests(ServerFixture serverFixture, ITestOutputHelper output)
|
||||||
{
|
{
|
||||||
if (serverFixture == null)
|
if (serverFixture == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(serverFixture));
|
throw new ArgumentNullException(nameof(serverFixture));
|
||||||
}
|
}
|
||||||
|
|
||||||
_serverFixture = serverFixture;
|
_serverFixture = serverFixture;
|
||||||
|
_output = output;
|
||||||
}
|
}
|
||||||
|
|
||||||
[ConditionalFact]
|
[ConditionalFact]
|
||||||
|
|
@ -126,6 +131,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
{
|
{
|
||||||
var baseUrl = _serverFixture.BaseUrl;
|
var baseUrl = _serverFixture.BaseUrl;
|
||||||
var loggerFactory = new LoggerFactory();
|
var loggerFactory = new LoggerFactory();
|
||||||
|
loggerFactory.AddXUnit(_output, LogLevel.Debug);
|
||||||
|
|
||||||
var connection = new ClientConnection(new Uri(baseUrl + "/echo"), loggerFactory);
|
var connection = new ClientConnection(new Uri(baseUrl + "/echo"), loggerFactory);
|
||||||
try
|
try
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,11 @@ namespace Microsoft.Extensions.Logging
|
||||||
{
|
{
|
||||||
self.AddProvider(new XUnitLoggerProvider(output));
|
self.AddProvider(new XUnitLoggerProvider(output));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void AddXUnit(this ILoggerFactory self, ITestOutputHelper output, LogLevel minLevel)
|
||||||
|
{
|
||||||
|
self.AddProvider(new XUnitLoggerProvider(output, minLevel));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -23,15 +28,22 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
public class XUnitLoggerProvider : ILoggerProvider
|
public class XUnitLoggerProvider : ILoggerProvider
|
||||||
{
|
{
|
||||||
private ITestOutputHelper _output;
|
private ITestOutputHelper _output;
|
||||||
|
private LogLevel _minLevel;
|
||||||
|
|
||||||
public XUnitLoggerProvider(ITestOutputHelper output)
|
public XUnitLoggerProvider(ITestOutputHelper output)
|
||||||
|
: this(output, LogLevel.Trace)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public XUnitLoggerProvider(ITestOutputHelper output, LogLevel minLevel)
|
||||||
{
|
{
|
||||||
_output = output;
|
_output = output;
|
||||||
|
_minLevel = minLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ILogger CreateLogger(string categoryName)
|
public ILogger CreateLogger(string categoryName)
|
||||||
{
|
{
|
||||||
return new XUnitLogger(_output, categoryName, LogLevel.Trace);
|
return new XUnitLogger(_output, categoryName, _minLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue