#4 Add logging to debug flaky tests.
This commit is contained in:
parent
7dd670e192
commit
9b5a476622
|
|
@ -8,6 +8,7 @@ using Microsoft.AspNet.Server.Testing;
|
|||
using Microsoft.AspNet.Testing.xunit;
|
||||
using Microsoft.Framework.Logging;
|
||||
using Xunit;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace ServerComparison.FunctionalTests
|
||||
{
|
||||
|
|
@ -101,7 +102,16 @@ namespace ServerComparison.FunctionalTests
|
|||
}, logger, deploymentResult.HostShutdownToken);
|
||||
|
||||
var responseText = await response.Content.ReadAsStringAsync();
|
||||
Assert.Equal("Hello World", responseText);
|
||||
try
|
||||
{
|
||||
Assert.Equal("Hello World", responseText);
|
||||
}
|
||||
catch (XunitException)
|
||||
{
|
||||
logger.LogWarning(response.ToString());
|
||||
logger.LogWarning(responseText);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ using Microsoft.AspNet.Server.Testing;
|
|||
using Microsoft.AspNet.Testing.xunit;
|
||||
using Microsoft.Framework.Logging;
|
||||
using Xunit;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace ServerComparison.FunctionalTests
|
||||
{
|
||||
|
|
@ -51,19 +52,28 @@ namespace ServerComparison.FunctionalTests
|
|||
}, logger, deploymentResult.HostShutdownToken);
|
||||
|
||||
var responseText = await response.Content.ReadAsStringAsync();
|
||||
Assert.Equal("Hello World", responseText);
|
||||
try
|
||||
{
|
||||
Assert.Equal("Hello World", responseText);
|
||||
|
||||
responseText = await httpClient.GetStringAsync("/Anonymous");
|
||||
Assert.Equal("Anonymous?True", responseText);
|
||||
responseText = await httpClient.GetStringAsync("/Anonymous");
|
||||
Assert.Equal("Anonymous?True", responseText);
|
||||
|
||||
response = await httpClient.GetAsync("/Restricted");
|
||||
Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);
|
||||
Assert.Contains("NTLM", response.Headers.WwwAuthenticate.ToString());
|
||||
response = await httpClient.GetAsync("/Restricted");
|
||||
Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);
|
||||
Assert.Contains("NTLM", response.Headers.WwwAuthenticate.ToString());
|
||||
|
||||
httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true };
|
||||
httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) };
|
||||
responseText = await httpClient.GetStringAsync("/Restricted");
|
||||
Assert.Equal("NotAnonymous", responseText);
|
||||
httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true };
|
||||
httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) };
|
||||
responseText = await httpClient.GetStringAsync("/Restricted");
|
||||
Assert.Equal("NotAnonymous", responseText);
|
||||
}
|
||||
catch (XunitException)
|
||||
{
|
||||
logger.LogWarning(response.ToString());
|
||||
logger.LogWarning(responseText);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,6 +119,7 @@ namespace ServerComparison.FunctionalTests
|
|||
}
|
||||
catch (XunitException)
|
||||
{
|
||||
logger.LogWarning(response.ToString());
|
||||
logger.LogWarning(responseText);
|
||||
throw;
|
||||
}
|
||||
|
|
@ -130,11 +131,10 @@ namespace ServerComparison.FunctionalTests
|
|||
|
||||
private static async Task CheckContentLengthAsync(HttpClient client, ILogger logger)
|
||||
{
|
||||
string responseText = string.Empty;
|
||||
var response = await client.GetAsync("contentlength");
|
||||
var responseText = await response.Content.ReadAsStringAsync();
|
||||
try
|
||||
{
|
||||
var response = await client.GetAsync("contentlength");
|
||||
responseText = await response.Content.ReadAsStringAsync();
|
||||
Assert.Equal("Content Length", responseText);
|
||||
Assert.Null(response.Headers.TransferEncodingChunked);
|
||||
Assert.Null(response.Headers.ConnectionClose);
|
||||
|
|
@ -142,6 +142,7 @@ namespace ServerComparison.FunctionalTests
|
|||
}
|
||||
catch (XunitException)
|
||||
{
|
||||
logger.LogWarning(response.ToString());
|
||||
logger.LogWarning(responseText);
|
||||
throw;
|
||||
}
|
||||
|
|
@ -149,11 +150,10 @@ namespace ServerComparison.FunctionalTests
|
|||
|
||||
private static async Task CheckConnectionCloseAsync(HttpClient client, ILogger logger)
|
||||
{
|
||||
string responseText = string.Empty;
|
||||
var response = await client.GetAsync("connectionclose");
|
||||
var responseText = await response.Content.ReadAsStringAsync();
|
||||
try
|
||||
{
|
||||
var response = await client.GetAsync("connectionclose");
|
||||
responseText = await response.Content.ReadAsStringAsync();
|
||||
Assert.Equal("Connnection Close", responseText);
|
||||
Assert.True(response.Headers.ConnectionClose, "/connectionclose, closed?");
|
||||
Assert.Null(response.Headers.TransferEncodingChunked);
|
||||
|
|
@ -161,6 +161,7 @@ namespace ServerComparison.FunctionalTests
|
|||
}
|
||||
catch (XunitException)
|
||||
{
|
||||
logger.LogWarning(response.ToString());
|
||||
logger.LogWarning(responseText);
|
||||
throw;
|
||||
}
|
||||
|
|
@ -168,11 +169,10 @@ namespace ServerComparison.FunctionalTests
|
|||
|
||||
private static async Task CheckChunkedAsync(HttpClient client, ILogger logger)
|
||||
{
|
||||
string responseText = string.Empty;
|
||||
var response = await client.GetAsync("chunked");
|
||||
var responseText = await response.Content.ReadAsStringAsync();
|
||||
try
|
||||
{
|
||||
var response = await client.GetAsync("chunked");
|
||||
responseText = await response.Content.ReadAsStringAsync();
|
||||
Assert.Equal("Chunked", responseText);
|
||||
Assert.True(response.Headers.TransferEncodingChunked, "/chunked, chunked?");
|
||||
Assert.Null(response.Headers.ConnectionClose);
|
||||
|
|
@ -180,6 +180,7 @@ namespace ServerComparison.FunctionalTests
|
|||
}
|
||||
catch (XunitException)
|
||||
{
|
||||
logger.LogWarning(response.ToString());
|
||||
logger.LogWarning(responseText);
|
||||
throw;
|
||||
}
|
||||
|
|
@ -187,11 +188,10 @@ namespace ServerComparison.FunctionalTests
|
|||
|
||||
private static async Task CheckManuallyChunkedAsync(HttpClient client, ILogger logger)
|
||||
{
|
||||
string responseText = string.Empty;
|
||||
var response = await client.GetAsync("manuallychunked");
|
||||
var responseText = await response.Content.ReadAsStringAsync();
|
||||
try
|
||||
{
|
||||
var response = await client.GetAsync("manuallychunked");
|
||||
responseText = await response.Content.ReadAsStringAsync();
|
||||
Assert.Equal("Manually Chunked", responseText);
|
||||
Assert.True(response.Headers.TransferEncodingChunked, "/manuallychunked, chunked?");
|
||||
Assert.Null(response.Headers.ConnectionClose);
|
||||
|
|
@ -199,6 +199,7 @@ namespace ServerComparison.FunctionalTests
|
|||
}
|
||||
catch (XunitException)
|
||||
{
|
||||
logger.LogWarning(response.ToString());
|
||||
logger.LogWarning(responseText);
|
||||
throw;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue