-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OSOE-402: Custom logging instead of NLog-based one #419
base: dev
Are you sure you want to change the base?
Conversation
await Task.WhenAll( | ||
logsArray.Select(async log => | ||
$"# Log name: {log.Name}" + | ||
Environment.NewLine + | ||
Environment.NewLine + | ||
await LogLinesToFormattedStringAsync(log)))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach may change the order of the log records. I would be surprised if we will have more than a few hundred log records here. Do we need parallelization?
} | ||
} | ||
|
||
public sealed class FakeLoggerApplicationLogEntry : IApplicationLogEntry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be a record
.
public record FakeLoggerApplicationLogEntry(FakeLogRecord LogRecord) : IApplicationLogEntry
{
public LogLevel Level => LogRecord.Level;
public EventId Id => LogRecord.Id;
public Exception Exception => LogRecord.Exception;
public string Message => LogRecord.Message;
public string Category => LogRecord.Category;
public DateTimeOffset Timestamp => LogRecord.Timestamp;
public override string ToString() => FormatLogRecord(LogRecord);
public static string FormatLogRecord(FakeLogRecord record) =>
StringHelper.CreateInvariant($"{record.Timestamp:yyyy-MM-dd HH:mm:ss.fff} [{record.Level}] {record.Category}: {record.Message}") +
(record.Exception != null ? record.Exception.ToString() : string.Empty);
}
@@ -46,7 +46,6 @@ public async Task<Uri> RunOperationAndSnapshotIfNewAsync(AppInitializer appIniti | |||
|
|||
var result = await appInitializer(); | |||
await result.Context.Application.TakeSnapshotAsync(_snapshotDirectoryPath); | |||
await result.Context.Application.ResumeAsync(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to myself: This was a question mark, but the instance is resumed in TakeSnapshotInnerAsync
.
OSOE-402
Fixes #206
To be added to the release notes on the next release:
Breaking changes in logging during UI tests
One of the implicit assertions that the UI Testing Toolbox does automatically is checking the Orchard Core application logs for any errors. By default, any error fails the test.
Previously, this relied on the tested web app using NLog for logging, and it parsed NLog log files. This not only required the app to use NLog over Serilog (that Orchard also supports out of the box) or any other logging framework, but it also depended on the structure of an otherwise freely configurable textual log format.
Now, the UI Testing Toolbox configured the app to use
FakeLogger
in addition to any logging framework it has set up, and uses it for assertions.FakeLogger
not only doesn't need anything specific in the app, but it also lets you access and assert on log entries in a structured, statically typed way.Using NLog is still
What changed
IApplicationLog
andIApplicationLogEntry
instances.LogsShouldBeEmptyAsync
andGetLogOutputAsync
methods are changed, see the diff.CreateAppLogAssertionForSecurityScan
andCreateAppLogAssertionForSecurityScan
work the same but were moved into theLombiq.Tests.UI.SecurityScanning
namespace.OrchardCoreConfiguration.AfterFakeLoggingConfiguration
event handler is exposed to change the default configuration ofFakeLogger
.OrchardCoreUITestExecutorConfiguration.AssertAppLogsCanContainWarningsAsync
andOrchardCoreUITestExecutorConfiguration.AssertAppLogsCanContainWarningsAndCacheFolderErrorsAsync
are no longer available.How to adapt
OrchardCoreUITestExecutorConfiguration.AssertAppLogsCanContainCacheFolderErrorsAsync
instead ofOrchardCoreUITestExecutorConfiguration.AssertAppLogsCanContainWarningsAndCacheFolderErrorsAsync
.OrchardCoreUITestExecutorConfiguration.AssertAppLogsCanContainWarningsAsync
is not needed, since the new behavior is to not log warnings in the first place.Lombiq.Tests.UI.Samples.UITestBase
, see the diff. Check them out if you have custom app log assertion code.