VSTest.Console when run with /Logger:Console does not print debug output from test method
Asked Answered
G

2

8

I am using Visual Studio 2015. I am trying to print some statements just for tracking a very long running test. When using VSTest.Console with /Logger:trx the debug output (whether we use Console.WriteLine(), Debug.Writeline() or Trace.WriteLine()) does go into the trx file which gets generated. However, when run with /Logger:Console the custom debug output does not show on the console output: only the test result shows up. I have even written my own extension by referring to:

https://blogs.msdn.microsoft.com/vikramagrawal/2012/07/26/writing-loggers-for-command-line-test-runner-vstest-console-exe/

However, it is not clear how to send a TestMessage from inside a test so that the TestMessageHandler gets called and output gets printed.

I think an extension may actually be redundant here and I may be able to use the console logger which comes as part of Visual Studio Extensions. Perhaps I need to make a specific call to send the informational message, or need to use a proper command line switch.

I am using the following command right now:

Vstest.Console.exe <Test dll> /logger:Console

The test runs but produces only the following output:

Starting test execution, please wait...
Passed   TestMethod1

Total tests: 1. Passed: 1. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 3.3929 Seconds

Whereas the trx file has following sections under output section which includes the console.writeline() and debug.trace() outputs:
(The text being shown below is just for the sake of example)

<Output>
    <StdOut>
    Test Started
    Test Ended
    Debug Trace:
    Test started
    Test ended
    </StdOut>
</Output>

I am wondering if it might also be possible to show the same information when using the Console logger.

Grimm answered 26/6, 2017 at 19:16 Comment(0)
K
2

The behavior is now changed in VS 2017 15.5.2+, it now emits the output.

Kilovolt answered 20/12, 2017 at 18:27 Comment(2)
Great! I will test this out when I get a chance. Thanks!Grimm
it works only for failed tests, in passed tests it still doesn't show debug messagesUlphi
A
1

You have to increase the verbosity:

vstest.console.exe <Test dll> /logger:console;verbosity=detailed

Source:
https://github.com/microsoft/vstest/blob/a7bb423c9f7104082cca5cbaf405c1166d2da760/docs/report.md#1-console-logger

For vstest.console.exe : /logger:console[;verbosity=<Defaults to "normal">]

Argument "verbosity" define the verbosity level of console logger. Allowed values for verbosity are "quiet", "minimal", "normal" and "detailed".

Aarhus answered 26/1 at 11:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.