testfx icon indicating copy to clipboard operation
testfx copied to clipboard

Console logger support during test execution

Open MarcoK80 opened this issue 1 year ago • 2 comments

We use a console and file logger during test execution. The console is not redirected to the Test execution during the test run. This should be configurable so if you run the test e.g. on a hosted agent that the test execution itself is always having the console log output in a continues flow.

E.g.

Test is having the simple Console loggerprovider. This is displayed after test run in Visual studio

image

In Azure pipeline this is hidden:

image

Background and Motivation

This would help detecting issues e.g. when the agent cancels or in the scenario when a time out occurs and you want to see which test and test step was executed. The console log should be displayed during test execution and not after. The option to store the log in a file is not useful if the agent gets shutdown or crashed.

Example: We are trying to analyse a test run that crashes / shutdown the agent. There is no way to diagnose what happened:

image

Proposed Feature

Redirect console output in flow of the test run and always show it. This should be based on configuration.

MarcoK80 avatar Sep 02 '24 14:09 MarcoK80

You can try to set the CaptureTraceOutput to false with a runsetting https://learn.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file?view=vs-2022#mstest-element

MarcoRossignoli avatar Sep 02 '24 14:09 MarcoRossignoli

We are trying to analyse a test run that crashes / shutdown the agent. There is no way to diagnose what happened:

You can enable crash dump extension https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-platform-extensions-diagnostics#crash-dump

If you're using MSTest.Sdk it's enough to add the msbuild property <EnableMicrosoftTestingExtensionsCrashDump>true</EnableMicrosoftTestingExtensionsCrashDump> to opt-in the extension and after you can pass the command line like in the documentation https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-mstest-sdk#enable-or-disable-extensions

MarcoRossignoli avatar Sep 02 '24 14:09 MarcoRossignoli

seems this is resolved?

SimonCropp avatar May 30 '25 01:05 SimonCropp