VSTS + Visual Studio Test: Add additional logs to test output

Viewed 1461

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.

2 Answers

They must have added this ability since this question was asked. I simply added Console.WriteLine("some output...") to my xUnit test, and I saw the output within the VsTest task logs.

Related