Replace console logger with ITestOutputHelper (#64)
This commit is contained in:
parent
1ae7d6dc39
commit
a2914ab483
|
|
@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Testing.xunit;
|
||||||
using Microsoft.DotNet.PlatformAbstractions;
|
using Microsoft.DotNet.PlatformAbstractions;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
using Xunit.Abstractions;
|
||||||
using Xunit.Sdk;
|
using Xunit.Sdk;
|
||||||
|
|
||||||
namespace ServerComparison.FunctionalTests
|
namespace ServerComparison.FunctionalTests
|
||||||
|
|
@ -16,6 +17,13 @@ namespace ServerComparison.FunctionalTests
|
||||||
// Uses ports ranging 5061 - 5069.
|
// Uses ports ranging 5061 - 5069.
|
||||||
public class HelloWorldTests
|
public class HelloWorldTests
|
||||||
{
|
{
|
||||||
|
private readonly ITestOutputHelper _output;
|
||||||
|
|
||||||
|
public HelloWorldTests(ITestOutputHelper output)
|
||||||
|
{
|
||||||
|
_output = output;
|
||||||
|
}
|
||||||
|
|
||||||
// Tests disabled on x86 because of https://github.com/aspnet/Hosting/issues/601
|
// Tests disabled on x86 because of https://github.com/aspnet/Hosting/issues/601
|
||||||
[ConditionalTheory]
|
[ConditionalTheory]
|
||||||
[OSSkipCondition(OperatingSystems.Linux)]
|
[OSSkipCondition(OperatingSystems.Linux)]
|
||||||
|
|
@ -63,10 +71,11 @@ namespace ServerComparison.FunctionalTests
|
||||||
|
|
||||||
public async Task HelloWorld(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl, ApplicationType applicationType)
|
public async Task HelloWorld(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl, ApplicationType applicationType)
|
||||||
{
|
{
|
||||||
|
var loggerName = string.Format("HelloWorld:{0}:{1}:{2}:{3}", serverType, runtimeFlavor, architecture, applicationType);
|
||||||
|
Console.WriteLine("Running test for " + loggerName);
|
||||||
var logger = new LoggerFactory()
|
var logger = new LoggerFactory()
|
||||||
.AddConsole()
|
.AddXunit(_output)
|
||||||
.CreateLogger(string.Format("HelloWorld:{0}:{1}:{2}:{3}", serverType, runtimeFlavor, architecture, applicationType));
|
.CreateLogger(loggerName);
|
||||||
|
|
||||||
using (logger.BeginScope("HelloWorldTest"))
|
using (logger.BeginScope("HelloWorldTest"))
|
||||||
{
|
{
|
||||||
var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture)
|
var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture)
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Testing.xunit;
|
||||||
using Microsoft.DotNet.PlatformAbstractions;
|
using Microsoft.DotNet.PlatformAbstractions;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
using Xunit.Abstractions;
|
||||||
using Xunit.Sdk;
|
using Xunit.Sdk;
|
||||||
|
|
||||||
namespace ServerComparison.FunctionalTests
|
namespace ServerComparison.FunctionalTests
|
||||||
|
|
@ -18,6 +19,13 @@ namespace ServerComparison.FunctionalTests
|
||||||
// Uses ports ranging 5050 - 5060.
|
// Uses ports ranging 5050 - 5060.
|
||||||
public class NtlmAuthenticationTests
|
public class NtlmAuthenticationTests
|
||||||
{
|
{
|
||||||
|
private readonly ITestOutputHelper _output;
|
||||||
|
|
||||||
|
public NtlmAuthenticationTests(ITestOutputHelper output)
|
||||||
|
{
|
||||||
|
_output = output;
|
||||||
|
}
|
||||||
|
|
||||||
[ConditionalTheory, Trait("ServerComparison.FunctionalTests", "ServerComparison.FunctionalTests")]
|
[ConditionalTheory, Trait("ServerComparison.FunctionalTests", "ServerComparison.FunctionalTests")]
|
||||||
[OSSkipCondition(OperatingSystems.Linux)]
|
[OSSkipCondition(OperatingSystems.Linux)]
|
||||||
[OSSkipCondition(OperatingSystems.MacOSX)]
|
[OSSkipCondition(OperatingSystems.MacOSX)]
|
||||||
|
|
@ -29,9 +37,11 @@ namespace ServerComparison.FunctionalTests
|
||||||
[InlineData(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, "http://localhost:5053/", ApplicationType.Standalone)]
|
[InlineData(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, "http://localhost:5053/", ApplicationType.Standalone)]
|
||||||
public async Task NtlmAuthentication(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl, ApplicationType applicationType)
|
public async Task NtlmAuthentication(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl, ApplicationType applicationType)
|
||||||
{
|
{
|
||||||
|
var loggerName = string.Format("Ntlm:{0}:{1}:{2}:{3}", serverType, runtimeFlavor, architecture, applicationType);
|
||||||
|
Console.WriteLine("Running test for " + loggerName);
|
||||||
var logger = new LoggerFactory()
|
var logger = new LoggerFactory()
|
||||||
.AddConsole()
|
.AddXunit(_output)
|
||||||
.CreateLogger(string.Format("Ntlm:{0}:{1}:{2}:{3}", serverType, runtimeFlavor, architecture, applicationType));
|
.CreateLogger(loggerName);
|
||||||
|
|
||||||
using (logger.BeginScope("NtlmAuthenticationTest"))
|
using (logger.BeginScope("NtlmAuthenticationTest"))
|
||||||
{
|
{
|
||||||
|
|
@ -143,4 +153,4 @@ namespace ServerComparison.FunctionalTests
|
||||||
#elif NETCOREAPP1_1
|
#elif NETCOREAPP1_1
|
||||||
#else
|
#else
|
||||||
#error target frameworks need to be updated
|
#error target frameworks need to be updated
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ using Microsoft.DotNet.PlatformAbstractions;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Net.Http.Headers;
|
using Microsoft.Net.Http.Headers;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
using Xunit.Abstractions;
|
||||||
using Xunit.Sdk;
|
using Xunit.Sdk;
|
||||||
|
|
||||||
namespace ServerComparison.FunctionalTests
|
namespace ServerComparison.FunctionalTests
|
||||||
|
|
@ -24,6 +25,12 @@ namespace ServerComparison.FunctionalTests
|
||||||
{
|
{
|
||||||
// NGinx's default min size is 20 bytes
|
// NGinx's default min size is 20 bytes
|
||||||
private static readonly string HelloWorldBody = "Hello World;" + new string('a', 20);
|
private static readonly string HelloWorldBody = "Hello World;" + new string('a', 20);
|
||||||
|
private readonly ITestOutputHelper _output;
|
||||||
|
|
||||||
|
public ResponseCompressionTests(ITestOutputHelper output)
|
||||||
|
{
|
||||||
|
_output = output;
|
||||||
|
}
|
||||||
|
|
||||||
[ConditionalTheory]
|
[ConditionalTheory]
|
||||||
[OSSkipCondition(OperatingSystems.Linux)]
|
[OSSkipCondition(OperatingSystems.Linux)]
|
||||||
|
|
@ -119,9 +126,11 @@ namespace ServerComparison.FunctionalTests
|
||||||
|
|
||||||
public async Task ResponseCompression(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl, Func<HttpClient, ILogger, Task> scenario, ApplicationType applicationType, bool hostCompression)
|
public async Task ResponseCompression(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl, Func<HttpClient, ILogger, Task> scenario, ApplicationType applicationType, bool hostCompression)
|
||||||
{
|
{
|
||||||
|
var loggerName = string.Format("ResponseCompression:{0}:{1}:{2}:{3}", serverType, runtimeFlavor, architecture, applicationType);
|
||||||
|
Console.WriteLine("Running test for " + loggerName);
|
||||||
var logger = new LoggerFactory()
|
var logger = new LoggerFactory()
|
||||||
.AddConsole()
|
.AddXunit(_output)
|
||||||
.CreateLogger(string.Format("ResponseCompression:{0}:{1}:{2}:{3}", serverType, runtimeFlavor, architecture, applicationType));
|
.CreateLogger(loggerName);
|
||||||
|
|
||||||
using (logger.BeginScope("ResponseCompressionTest"))
|
using (logger.BeginScope("ResponseCompressionTest"))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ using Microsoft.DotNet.PlatformAbstractions;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Net.Http.Headers;
|
using Microsoft.Net.Http.Headers;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
using Xunit.Abstractions;
|
||||||
using Xunit.Sdk;
|
using Xunit.Sdk;
|
||||||
|
|
||||||
namespace ServerComparison.FunctionalTests
|
namespace ServerComparison.FunctionalTests
|
||||||
|
|
@ -19,6 +20,13 @@ namespace ServerComparison.FunctionalTests
|
||||||
// Uses ports ranging 5080 - 5099.
|
// Uses ports ranging 5080 - 5099.
|
||||||
public class ResponseTests
|
public class ResponseTests
|
||||||
{
|
{
|
||||||
|
private readonly ITestOutputHelper _output;
|
||||||
|
|
||||||
|
public ResponseTests(ITestOutputHelper output)
|
||||||
|
{
|
||||||
|
_output = output;
|
||||||
|
}
|
||||||
|
|
||||||
[ConditionalTheory]
|
[ConditionalTheory]
|
||||||
[OSSkipCondition(OperatingSystems.Linux)]
|
[OSSkipCondition(OperatingSystems.Linux)]
|
||||||
[OSSkipCondition(OperatingSystems.MacOSX)]
|
[OSSkipCondition(OperatingSystems.MacOSX)]
|
||||||
|
|
@ -156,9 +164,11 @@ namespace ServerComparison.FunctionalTests
|
||||||
|
|
||||||
public async Task ResponseFormats(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl, Func<HttpClient, ILogger, Task> scenario, ApplicationType applicationType)
|
public async Task ResponseFormats(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl, Func<HttpClient, ILogger, Task> scenario, ApplicationType applicationType)
|
||||||
{
|
{
|
||||||
|
var loggerName = string.Format("ResponseFormats:{0}:{1}:{2}:{3}", serverType, runtimeFlavor, architecture, applicationType);
|
||||||
|
Console.WriteLine("Running test for " + loggerName);
|
||||||
var logger = new LoggerFactory()
|
var logger = new LoggerFactory()
|
||||||
.AddConsole()
|
.AddXunit(_output)
|
||||||
.CreateLogger(string.Format("ResponseFormats:{0}:{1}:{2}:{3}", serverType, runtimeFlavor, architecture, applicationType));
|
.CreateLogger(loggerName);
|
||||||
|
|
||||||
using (logger.BeginScope("ResponseFormatsTest"))
|
using (logger.BeginScope("ResponseFormatsTest"))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Server.IntegrationTesting" Version="$(AspNetCoreLabsVersion)" />
|
<PackageReference Include="Microsoft.AspNetCore.Server.IntegrationTesting" Version="$(AspNetCoreLabsVersion)" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(AspNetCoreVersion)" />
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(AspNetCoreVersion)" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(AspNetCoreVersion)" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Testing" Version="$(AspNetCoreVersion)" />
|
||||||
<PackageReference Include="Microsoft.Extensions.PlatformAbstractions" Version="$(AspNetCoreVersion)" />
|
<PackageReference Include="Microsoft.Extensions.PlatformAbstractions" Version="$(AspNetCoreVersion)" />
|
||||||
<PackageReference Include="Microsoft.Dotnet.PlatformAbstractions" Version="$(AspNetCoreVersion)" />
|
<PackageReference Include="Microsoft.Dotnet.PlatformAbstractions" Version="$(AspNetCoreVersion)" />
|
||||||
<PackageReference Include="Microsoft.Net.Http.Headers" Version="$(AspNetCoreVersion)" />
|
<PackageReference Include="Microsoft.Net.Http.Headers" Version="$(AspNetCoreVersion)" />
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue