Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/ServiceControl.AcceptanceTesting/NServiceBusAcceptanceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using NServiceBus.AcceptanceTesting;
using NServiceBus.AcceptanceTesting.Customization;
using NUnit.Framework;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;

/// <summary>
Expand Down Expand Up @@ -49,6 +50,22 @@ public void TearDown()

TestContext.Out.WriteLine($@"Context:
{string.Join(Environment.NewLine, scenarioContext.GetType().GetProperties().Select(p => $"{p.Name} = {p.GetValue(scenarioContext, null)}"))}");

var result = TestExecutionContext.CurrentContext.CurrentResult.ResultState;

if (result == ResultState.Failure || result == ResultState.Error)
{
// The test endpoints only log here. ServiceControl's own host logs here too, on top of
// the live output it already writes, so its lines appear twice for a failed test.
TestContext.Out.WriteLine();
TestContext.Out.WriteLine($"Log entries (log level: {scenarioContext.LogLevel}):");
TestContext.Out.WriteLine("--- Start log entries ---------------------------------------------------");
foreach (var logEntry in scenarioContext.Logs)
{
TestContext.Out.WriteLine($"{logEntry.Timestamp:T} {logEntry.Level} {logEntry.Endpoint ?? TestContext.CurrentContext.Test.Name}: {logEntry.Message}");
}
TestContext.Out.WriteLine("--- End log entries -----------------------------------------------------");
}
}
}
}