VSTest is printing using Console.WriteLine instead of using the logger
See original GitHub issueDescription
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
- Clone https://github.com/dotnet/iot/
- Replace following (“Test”) task https://github.com/dotnet/iot/blob/a5a53b5a3a287638df0176c483fcb1f3b2fef7f0/build.proj#L59 with
<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
- Run build.cmd/build.sh (in the root directory)
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:
- Created 4 years ago
- Reactions:4
- Comments:7 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
FYI #2702 addresses the issue, but has been waiting for ages now. I’m rebasing from time to time…
@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.