How to write to the debugging window in unit testing?
Trace.WriteLine() does not work for some reason. Debug. not comfortable
How to write to the debugging window in unit testing?
Trace.WriteLine() does not work for some reason. Debug. not comfortable
You can write to the debugging window during testing using either Console.WriteLine() or using Trace.WriteLine()
Console.WriteLine Example [TestMethod] public void TestConsoleWriteLine() { Assert.IsTrue(true); Console.WriteLine(@"Тест 'TestConsoleWriteLine' успешно пройден"); } Trace.WriteLine Example [TestMethod] public void TestTraceWriteLine() { Assert.IsTrue(true); Trace.WriteLine(@"Тест 'TestTraceWriteLine' успешно пройден"); } 
If none of these methods works, you need to look at the settings for VisualStudio and Resharper . Go to settings Resharper -> Options... -> Tools -> Unit Testing and see how you are configured there, try to make changes. Although, it all depends on the version of Resharper and VisualStudio .
Saw a comment about the exception: If your test does not expect Exception , you need to attach the ExpectedExceptionAttribute attribute to the test method, which indicates that an exception is expected during the execution of the test method.
It actually works, but a little differently than usual. I ran the simplest test:
[TestClass] public class UnitTest1 { [TestMethod] public void TestMethod1() { Trace.WriteLine("Tracing from test"); } } and after it was run in the report (inside the test browser), the Output link appeared.
On it the window opens:
Yes, it is not as convenient as usual, and the output appears only all and only after the test run.
Console.WriteLine() and TestContext.WriteLIne() (if you use MSTest). - andreychaSource: https://ru.stackoverflow.com/questions/562510/
All Articles