Skip to content

Commit

Permalink
Add -silent reporter which does not output anything
Browse files Browse the repository at this point in the history
  • Loading branch information
bradwilson committed Nov 17, 2023
1 parent 9cbad9a commit dc28c5d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/xunit.runner.reporters/SilentReporter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Xunit.Abstractions;

namespace Xunit.Runner.Reporters
{
public class SilentReporter : IRunnerReporter
{
public string Description =>
"turns off all output messages";

public bool IsEnvironmentallyEnabled =>
false;

public string RunnerSwitch =>
"silent";

public IMessageSink CreateMessageHandler(IRunnerLogger logger) =>
new SilentReporterMessageHandler();
}
}
18 changes: 18 additions & 0 deletions src/xunit.runner.reporters/SilentReporterMessageHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Collections.Generic;
using Xunit.Abstractions;
using Xunit.Sdk;

namespace Xunit.Runner.Reporters
{
public sealed class SilentReporterMessageHandler : LongLivedMarshalByRefObject, IMessageSinkWithTypes, IMessageSink
{
public void Dispose()
{ }

public bool OnMessage(IMessageSinkMessage message) =>
true;

public bool OnMessageWithTypes(IMessageSinkMessage message, HashSet<string> messageTypes) =>
true;
}
}

0 comments on commit dc28c5d

Please sign in to comment.