【问题标题】:How can I suppress NUnit console output?如何抑制 NUnit 控制台输出?
【发布时间】:2016-03-11 20:39:49
【问题描述】:

有没有办法抑制控制台输出上显示的 NUnit 错误和故障?

我尝试使用命令行选项:/xml、/out、/err。但我仍然在控制台中得到输出。

【问题讨论】:

    标签: nunit nunit-console


    【解决方案1】:

    从您对 /xml 选项的使用中,我可以看出您使用的是旧版本的 NUnit,但是对于新版本的答案也是一样的。

    无法更改控制台运行程序生成的报告输出。您可以将整个内容重定向到文件,甚至可以重定向到 null 设备,但您不能隐藏其中的部分内容。

    【讨论】:

      【解决方案2】:

      NUnit3 中,您可以像这样定义SetupFixture

      [SetUpFixture]
      public class TestSetup
      {
          [OneTimeSetUp]
          public void RunBeforeAnyTests()
          {
              // Disable console output from test methods
              Console.SetOut(TextWriter.Null);
          }
      
          [OneTimeTearDown]
          public void RunAfterAnyTests()
          {
              // Whatever should run after tests
          }
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-02-20
        • 2018-04-15
        • 1970-01-01
        • 2018-07-05
        • 1970-01-01
        相关资源
        最近更新 更多