Text output in UnitTests

When I run my unit tests, I would like to print and read how long it takes to run the function. I tried using Console.WriteLine () Trace.WriteLine (), but that did not work. Does anyone know the correct method I should use?

I have the following unit test

[TestMethod()]
public void ProductSerializationTest()
{

    Stopwatch swSerialization = new Stopwatch();
    swSerialization.Start();
    SerializeProductsToXML(dummyProductList, XMLFolderPath);
    swSerialization.Stop();
    //Print out swSerialization.Elapsed value
 }
+5
source share
3 answers

If you use Visual Studio with built-in test support, the output System.Diagnostics.Trace.WriteLinewill go to the report of test results. That is, after starting the test, double-click its entry in the list of test results, and the section "Trace debugging" appears in the test run report.

+5

Microsoft.VisualStudio.TestTools.UnitTesting, TestContext.WriteLine(). TestContext.


TestDriven NUnit, Console.WriteLine(), , .

+2

. . x, VS? , ,

Trace.WriteLine() , .

0

All Articles