Because ILogger<T> objects are frequently used in controllers and service classes, we cannot avoid them in unit tests. In this post, we will go over some common ways to work with ILogger<T> objects in unit testing.
- Replace
ILogger<T>withNullLogger<T> - Create a Real
ILogger<T>that Logs to Console - Mock an
ILogger<T>Object
Feel free to use the code in this repository as it is under MIT license.