问题
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.
回答1:
The behavior is now changed in VS 2017 15.5.2+, it now emits the output.
来源:https://stackoverflow.com/questions/44767110/vstest-console-when-run-with-loggerconsole-does-not-print-debug-output-from-te