quldude
quldude

Reputation: 539

How can I suppress NUnit console output?

Is there a way to suppress NUnit errors and failures displayed on console output?

I tried using the command line options: /xml, /out, /err. But still I get the output in the console.

Upvotes: 2

Views: 1599

Answers (2)

axuno
axuno

Reputation: 646

In NUnit3 you could define a SetupFixture like this:

[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
    }
}

Upvotes: 0

Charlie
Charlie

Reputation: 13726

From your use of the /xml option, I can see you are using an older version of NUnit, however, the answer is the same for newer ones as well.

There is no way to change the report output produced by the console runner. You can redirect the entire thing to a file, or even to the null device, but you can't suppress parts of it.

Upvotes: 3

Related Questions