gpt4 book ai didi

.net - 如何在 NUnit 3 的 Visual Studio 适配器中启用跟踪输出?

转载 作者:行者123 更新时间:2023-12-01 21:55:47 24 4
gpt4 key购买 nike

考虑:

[Test]
public void Test1()
{
Trace.TraceInformation("Hello");
}

从 Visual Studio 2015 运行它时,输出窗口(测试)不显示跟踪线:

------ Discover test started ------
NUnit Adapter 3.4.0.0: Test discovery starting
NUnit Adapter 3.4.0.0: Test discovery complete
========== Discover test finished: 9 found (0:00:01.325888) ==========
------ Run test started ------
NUnit Adapter 3.4.0.0: Test execution started
Running selected tests in C:\Projects\bla-bla.dll
NUnit3TestExecutor converted 9 of 9 NUnit test cases
NUnit Adapter 3.4.0.0: Test execution complete
========== Run test finished: 1 run (0:00:03.5445181) ==========

我记得它在 NUnit 2 和 Visual Studio 2013 上运行良好。我需要以某种方式打开它吗?

我的app.config没有覆盖默认值 <system.diagnostics> .

最佳答案

根据this discussion ,由于技术原因,他们删除了该内容。

替代解决方案可能是这样的:

using NUnit.Framework;

namespace MyUnitTest {
[TestFixture]
public class UnitTest1 {
[Test()]
public void Test1() {
var x = "Before Test";
TestContext.Progress.WriteLine(x);
x = "Hello";
TestContext.Progress.WriteLine(x);
Assert.IsTrue(x == "Hello");
x = "After Test";
TestContext.Progress.WriteLine(x);
}
}
}

给出的结果:

NUnit Adapter 3.4.1.0: Test execution started Running selected testsin C:\ProjectPath\MyUnitTest.dll NUnit3TestExecutor converted 1 of 1
NUnit test cases Before Test Hello After Test NUnit Adapter 3.4.1.0:
Test execution complete
========== Test execution complete: 1 run(0:00:00,7660762) ==========

结论

您不能再在 NUnit 的输出上使用 Trace

关于.net - 如何在 NUnit 3 的 Visual Studio 适配器中启用跟踪输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38744600/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com