使用 TestContext.WriteLine 重复输出

发布于 2024-09-15 17:14:04 字数 465 浏览 3 评论 0原文

我在 VS 2008 中做了一个“有序测试”,它执行了 4 个测试。它运行的 TestMethod 测试之一有几个 writeline 语句,如下所示:

TestContext.WriteLine("One");
TestContext.WriteLine("Two");
TestContext.WriteLine("Three");

我在结果的“附加信息”中收到的输出显示了以下输出:







我不认为测试方法运行了多次。我认为 writeline 输出只是以某种奇怪的方式进行缓冲。 如何解决此问题?

对于任何具有 TestContext writeline 语句的测试方法(至少在从有序测试调用时),我都会遇到此问题。

I've made an "ordered test" in VS 2008 which executes 4 tests. One of the TestMethod tests it runs has several writeline statements, like this:

TestContext.WriteLine("One");
TestContext.WriteLine("Two");
TestContext.WriteLine("Three");

The output I receive in the "Additional Information" of the results shows this output:

One
Two
Three
One
Two
One
Two

I don't think the test method is running multiple times. I think the writeline output is simply being buffered in some bizarre way. How do I fix this?

I get this problem with any test method that has TestContext writeline statements (at least when invoked from an ordered test).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文