We have an application and use VSTS for automated builds, tests and deployments. Everything works fine so far. I only have one problem. I'd like to add some additional logs to the test logs.
We added a simple 'Visual Studio Test' (V2) task to our build pipeline, which essentially executes all tests of all assemblies it can find (default settings). When I want to add additional logs I usually use Console.WriteLine("bla, bla, bla") and it shows up in the test output locally.
But the same thing doesn't work with VSTS test tasks. I only see the default output (e.g. 2017-05-30T09:10:48.5505381Z Passed   ValidatePassword_ShouldSucceed_WhenCorrectPasswordIsSet), but not the additional WriteLine() calls. I already tried several other WriteLines:
TestContext.WriteLine($"bla, bla, bla");
Console.WriteLine($"bla, bla, bla");
Trace.WriteLine($"bla, bla, bla");
Debug.WriteLine($"bla, bla, bla");
None of them worked. So I guess the output of the VSTS test task is somehow decoupled from the 'normal' console/debug/trace logs.
I guess there's an easy way to add logs to the output, but I just cannot find it.
Thanks for your help.
For now, vs test task only shows the output in log when the test is failed.

If the vs test step is passed, it won’t the the output message in log.
I posted an user voice Visual Studio Test task show standard output in VSTS build log, you can vote and follow up.
On the other hand, you can find the output in $(Build.SourcesDirectory)\TestResults\xx.trx for temporarily use:
  <Results>
    <UnitTestResult executionId="0ab084d5-e9cc-46af-898e-c57cae7a8ae7" testId="fd1a9d66-d059-cd84-23d7-f655dce255f5" testName="TestMethod1" computerName="computer" duration="00:00:00.0128766" startTime="2017-05-31T15:12:51.9527754+08:00" endTime="2017-05-31T15:12:52.0627885+08:00" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" outcome="Passed" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" relativeResultsDirectory="0ab084d5-e9cc-46af-898e-c57cae7a8ae7">
      <Output>
        <StdOut>bla, bla, bla</StdOut>
      </Output>
    </UnitTestResult>
    <UnitTestResult executionId="d54ccde2-5cbe-44be-8d02-e81130b8f370" testId="fd1a9d66-d059-cd84-23d7-f655dce255f5" testName="TestMethod1" computerName="computer" duration="00:00:00.0139917" startTime="2017-05-31T15:12:52.3167945+08:00" endTime="2017-05-31T15:12:52.4268050+08:00" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" outcome="Passed" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" relativeResultsDirectory="d54ccde2-5cbe-44be-8d02-e81130b8f370">
      <Output>
        <StdOut>bla, bla, bla</StdOut>
      </Output>
    </UnitTestResult>
  </Results>
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With