corvus-dotnet / corvus-dotnet/Corvus.Testing
Consider making functions controller logging synchronous
- Dominant language
- C#
- Stars
- 13
- Forks
- 11
- PR merge metrics
- No merged PRs in 30d
Description
We create a logger for the `FunctionsController` at https://github.com/corvus-dotnet/Corvus.Testing/blob/6cc8a94aa27a8a730f76a8e342a3a58711f54462/Solutions/Corvus.Testing.AzureFunctions.SpecFlow/Corvus/Testing/AzureFunctions/SpecFlow/FunctionsBindings.cs#L19
The problem with using the normal console logging functionality is that they are invisible to SpecFlow. Microsoft's console logger carefully avoids blocking the caller, dumping all log operations to a queue which it then drains on a dedicated thread. This does not work well with how SpecFlow+NUnit captures output: they essentially redirect `Console.Out` in-process. The console logger's use of a worker thread to write things out deferred effectively bypasses that.
If we want logging to be visible in test results, it looks like we have to call `Console.WriteLine` synchronously. (It's odd that there isn't some less flaky mechanism—there is actually a tracing interface, but its implementation appears just to call `Console.WriteLine`, and in any case, it doesn't seem that we can get hold of that tracing API.)
We'd need to write a custom `ILogger` that does this.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.