Skip to content
Open
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
33 changes: 33 additions & 0 deletions src/ServiceControl.AcceptanceTesting/NServiceBusAcceptanceTest.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
namespace ServiceControl.AcceptanceTesting
{
using System;
using System.Linq;
using System.Threading;
using NServiceBus.AcceptanceTesting;
using NServiceBus.AcceptanceTesting.Customization;
using NServiceBus.Logging;
using NUnit.Framework;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;

/// <summary>
/// Base class for all the NSB test that sets up our conventions
Expand Down Expand Up @@ -35,5 +39,34 @@ public void SetUp()
return testName + "." + endpointBuilder;
};
}

[TearDown]
public void TearDown()
{
if (!TestExecutionContext.CurrentContext.TryGetRunDescriptor(out var runDescriptor))
{
return;
}

var scenarioContext = runDescriptor.ScenarioContext;

TestContext.Out.WriteLine($@"Test settings:
{string.Join(Environment.NewLine, runDescriptor.Settings.Select(setting => $" {setting.Key}: {setting.Value}"))}");

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

if (TestExecutionContext.CurrentContext.CurrentResult.ResultState == ResultState.Failure || TestExecutionContext.CurrentContext.CurrentResult.ResultState == ResultState.Error)
{
TestContext.Out.WriteLine(string.Empty);
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 ---------------------------------------------------");
}
Comment on lines +59 to +69
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that SC seems to have its own mechanism of printing logs, I think we can remove this part (as first imperfect step towards better debugging ability)

}
}
}