Lombiq / UI-Testing-Toolbox

Web UI testing toolbox for Orchard Core applications with Selenium. It discovers so many issues that you'll get impostor syndrome.
BSD 3-Clause "New" or "Revised" License
17 stars 6 forks source link

Custom logging instead of NLog-based one (OSOE-402) #206

Open Piedone opened 1 year ago

Piedone commented 1 year ago

Currently, the UI Testing Toolbox depends on NLog. In OrchardApplicationFactory we configure NLog for logging, and OrchardCoreInstance.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

rikbosch commented 10 months ago

Could something like https://github.com/horsdal/InMemoryLogger/blob/master/src/InMemoryLogger.cs be a solution?

Piedone commented 10 months ago

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.

rikbosch commented 10 months ago

What about using OpenTelemetry for capturing logs / traces and metrics of a specific failed test?

Piedone commented 10 months ago

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.

Piedone commented 8 months ago

Perhaps the best would be to use FakeLogger. Then FakeLogCollector can be used to retrieve the log messages.

Piedone commented 6 months ago

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.

Piedone commented 2 months ago

It's important that we need to log URLs too, since this greatly improved troubleshooting from a failure dump.