How to write to Console.Out during execution of an MSTest test

后端 未结 5 1581
谎友^
谎友^ 2020-11-28 03:25

Context:
We have some users reporting issues with a file upload feature in our web application. It only happens occasionally and without any sp

5条回答
  •  日久生厌
    2020-11-28 04:21

    Use the Debug.WriteLine. This will display your message in the Output window immediately. The only restriction is that you must run your test in Debug mode.

    [TestMethod]
    public void TestMethod1()
    {
        Debug.WriteLine("Time {0}", DateTime.Now);
        System.Threading.Thread.Sleep(30000);
        Debug.WriteLine("Time {0}", DateTime.Now);
    }
    

    Output

    enter image description here

提交回复
热议问题