Diagnostics for examining logs in automated tests.
Available from v3.0
This interface is implemented by:
TestCaptureLogger
(see: TestCaptureLogger)TestCaptureLogger<T>
(see: TestCaptureLogger<T>)The ITestCaptureLogger.GetLogs()
method allows you to retrieve the logs within your test method. The property will be in sequence, timestamps will be incremental, however adjacent log entries created sufficiently close to one another may contain the same timestamp due to the resolution of the clock.
IReadOnlyList<LogEntry>
: A read only list of log entries. See LogEntry
The result of the method can be passed into RenderLogs()
extension method. See Renderer
The ITestCaptureLogger.GetLogEntriesWithExceptions()
method gets all the log entries generated via this logger in sequential order that have exception objects attached to them.
1
2
3
4
5
6
7
8
// Arrange
var logger = new TestCaptureLogger();
// Act: Do something using the logger
// Assert
var logs = logger.GetAllLogEntriesWithExceptions();
// logs is a read only list of LogEntry objects in sequential order.
IReadOnlyList<LogEntry>
: A read only list of log entries. See LogEntry
The result of the method can be passed into RenderLogs()
extension method. See Renderer
Clears all the logs in the Logger.
If you reuse the same logger in multiple tests, be careful that the tests do not run in parallel with one another.