question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

VSTest is printing using Console.WriteLine instead of using the logger

See original GitHub issue

Description

VSTest should be using logger instead of Console.WriteLine. I.e.: https://github.com/microsoft/vstest/blob/e6c198ca439603f0e81d723538894646032745f6/src/Microsoft.TestPlatform.Build/Tasks/VSTestTask.cs#L132 https://github.com/microsoft/vstest/blob/e6c198ca439603f0e81d723538894646032745f6/src/Microsoft.TestPlatform.Build/Tasks/VSTestTask.cs#L301

This is causing that in some cases output gets lost.

Steps to reproduce

  <Target Name="Test">
    <ItemGroup>
      <UnitTestProjects Include="$(MSBuildThisFileDirectory)src\devices\**\*.Tests.csproj" />
    </ItemGroup>
    <MSBuild Projects="@(UnitTestProjects)" Targets="VSTest"
        ContinueOnError="ErrorAndContinue" />
    <Error Condition="$(MSBuildLastTaskResult) != 'true'"
        Text="Unit tests failed. Please check the detailed log to find out which ones failed." />
  </Target>

Replacing will not be needed once linked PR is merged

If any property is passed to MSBuild task then output gets printed (because of luck it gets run on master node where Console.WriteLine works correctly)

Expected behavior

Test output is displayed

Actual behavior

Build fails but no errors get printed

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:4
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
mcartoixacommented, Jul 18, 2023

FYI #2702 addresses the issue, but has been waiting for ages now. I’m rebasing from time to time…

1reaction
krwqcommented, Jul 18, 2023

@mayankbansal018 @Evangelink do you have any ETA when this might be addressed? this is currently making vstests kinda useless in some scenarios for dotnet/iot because tests fail but we get not info what failed and issue is CI specific in our case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VSTest.Console when run with /Logger:Console does not ...
Console when run with /Logger:Console does not print debug output from test method. However, it is not clear how to send a TestMessage...
Read more >
How to view log output while tests are running in VS 2019 ...
My goal is to view log output in Visual Studio 2019 Pro, for all unit tests, while the tests are running. I tried...
Read more >
Vstest.console.exe always adds Console logger in update ...
Write messages) to the console if you included /logger:Console on the command line. Now, it always sends test output to the console, and...
Read more >
How to Write to Console in Unit Test in Visual Studio 2022
The easiest way to write output from the test is to use the Console. WriteLine method. It will write the string as the...
Read more >
Capturing Output
When xUnit.net v2 shipped with parallelization turned on by default, ... To see output from dotnet test , pass the command line option...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found