Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output logs even in the case of success #4947

Closed
AbhishekMarda opened this issue Mar 26, 2024 · 1 comment · Fixed by #4998
Closed

Output logs even in the case of success #4947

AbhishekMarda opened this issue Mar 26, 2024 · 1 comment · Fixed by #4998

Comments

@AbhishekMarda
Copy link

Currently I'm running MSTest through Azure Pipelines using a VSTest@3 task. I observe that the test output is only done in the case of a failure, but omitted completely in the case of a success. Is there a way to output the logs for a successful tests too?

And is there a way to get the live output of a test instead of only at the end?

@nohwnd
Copy link
Member

nohwnd commented Mar 27, 2024

Is there a way to output the logs for a successful tests too?

Yes, dotnet test --logger:"console;verbosity=detailed".

 dotnet test --logger:"console;verbosity=detailed" -tl:false
  Determining projects to restore...
  All projects are up-to-date for restore.
C:\Program Files\dotnet\sdk\9.0.100-preview.2.24127.10\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierIn
ference.targets(314,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support
-policy [S:\t\mstest115\mstest115.csproj]
  mstest115 -> S:\t\mstest115\bin\Debug\net9.0\mstest115.dll
  Passed TestMethod1 [3s 2ms]
  Outputs:
    Standard Output Messages:
   Hello,
   World

  Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: [3s 453ms]

And is there a way to get the live output of a test instead of only at the end?

Not yet, there is this env variable: VSTEST_EXPERIMENTAL_FORWARD_OUTPUT_FEATURE=1 which will forward the output from the process, but it depends on the test framework whether or not the output will reach console. In MSTest at least there is no way to suppress capturing the managed (via Console.Write or Console.WriteLine), so only native output would reach that forwarding.

The ability to disable capturing output was added MSTest and will be released in 3.4.0 microsoft/testfx#349

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants