Open Piedone opened 1 year ago
Could something like https://github.com/horsdal/InMemoryLogger/blob/master/src/InMemoryLogger.cs be a solution?
Yep, looks suitable. Through InMemoryLogger.RecordedLogs
we could also access the log entries.
In any case, the FailureDump should still contain a full log file.
What about using OpenTelemetry for capturing logs / traces and metrics of a specific failed test?
That could be useful for tracing tests in general, though well beyond the scope of this issue, which is about substituting the ILogger
implementation.
See also https://github.com/OrchardCMS/OrchardCore/issues/12251.
Perhaps the best would be to use FakeLogger
. Then FakeLogCollector
can be used to retrieve the log messages.
This would also allow us to better filter log messages. Thus, we wouldn't log ErrorController
's exception, to begin with, instead of filtering it out during assertion.
It's important that we need to log URLs too, since this greatly improved troubleshooting from a failure dump.
Currently, the UI Testing Toolbox depends on NLog. In
OrchardApplicationFactory
we configure NLog for logging, andOrchardCoreInstance.GetLogs()
we load the log files. Instead, while retaining support for the app under test to use NLog logging for its own reasons, we could have our custom in-memory logger just for testing. That'd collect log messages about errors and warnings, and we'd use that to check for log entries to fail the test.Decoupling the project from NLog would also prevent issues like this when Orchard updates its NLog version: https://github.com/OrchardCMS/OrchardCore/pull/11194#issuecomment-1281160575
Related: https://github.com/Lombiq/Open-Source-Orchard-Core-Extensions/pull/264#discussion_r1016836343
Jira issue