visual-studio-2015load-testingtest-project

Why can't I see any console or trace output when running load tests in VS 2015?


I've got DEBUG and TRACE defined. I've tried Trace.WriteLine, Debug.WriteLine, Console.WriteLine, and TestContext.WriteLine. In the Test Results window, I've added columns for Output (StdOut), Errors (StdError), Debug Trace, and Stack Trace. I've tried all the "Show output from" options available for different streams in the Output window. I've looked all over the output summary window with the graphs and stuff. And nowhere can I find a single byte of trace output.

I had the same problem with VS 2008, in which load tests were a new and crude feature... I thought the upgrade would make things easier, but it hasn't.

All over the web people talk about logging trace messages to a console in these tests as if it were the easiest and most obvious thing in the world. I have no trouble with this sort of trace output during normal debugging, only when running load-tests. Why can't I find a way to do it?

[UPDATE] I found a partial answer: I can see the trace output on test runs that fail. After a run with failures, the page of graphs and stats opens, and at various places, there's a link to the errors. Click that and open the Load Test Errors window, right-click an error and select View Details, and you get a page in which there's an "Additional Information" section, and that section includes any messages written with TestContext.WriteLine. There's also a Debug Trace section that has messages written with Debug.WriteLine.

But I don't see a way to look at this output for a successful run. (And it would be nice to be able to combine certain outputs into a single stream, but I guess I can see why one would have to implement that manually.)


Solution

  • After a lot of search, I have finally found the answer to this one. Please notice that as you noted, by the default setting, it logs only when there is an error (the log under additional information, in the error details screen) The setting for that is under "run settings" properties, section logging, property "Save Log on test Failure" which has the default value "true".

    Now to the solution. Beside that property, there is one called "Save Log Frequency for Completed Tests". The default value is 0. This property is used to save a test log for one out of N tests. If you like to have logs created 100% of time, you will then set it to 1. 1 out of 1 is 100%.

    After you have done this, to find the log, in the result screen (right click on the load test and choose "open and manage results.."), navigate to the "details" tab, which will show you some graphs. Hover your mouse pointer over the individual tests in the "virtual user activity chart", and you will see a link to the "test log" there. Voila! Mission accomplished.