Interface IRunnerReporter
This interface represents a reporter which is invoked by a test runner during test execution. The report can be explicitly invoked by a command line switch or implicitly invoked by being environmentally enabled (for example, a reporter that emits messages for TeamCity).
public interface IRunnerReporter
Properties
CanBeEnvironmentallyEnabled
Gets a value which indicates if it's possible for this reporter to be environmentally enabled.
bool CanBeEnvironmentallyEnabled { get; }
Property Value
Remarks
Note that this differs from IsEnvironmentallyEnabled which checks to see whether the conditions currently exist to environmentally enable the reporter. This value is used when constructing the console runner help output that lists which runners might be environmentally enabled.
Description
Gets the description of the reporter. This is typically used when showing the user the invocation option for the reporter.
string Description { get; }
Property Value
ForceNoLogo
Gets a value which indicates whether this runner wishes to force no logo. Useful for runners which are designed for purely parseable output (for example, JsonReporter).
bool ForceNoLogo { get; }
Property Value
IsEnvironmentallyEnabled
Gets a value which indicates whether the reporter should be environmentally enabled.
bool IsEnvironmentallyEnabled { get; }
Property Value
Remarks
When a runner reporter is environmentally enabled in Microsoft Testing Platform
CLI mode (or dotnet test), by default all realtime output is filtered except
calls to LogRaw(string) (unless the user has specified the
--xunit-info switch). Environmentally enabled reporters that require
realtime console output (for example, to send formatted messages to a CI system
which parses the console output) must use LogRaw(string) to
ensure those messages will always be visible. All other messages will always be
output to the Microsoft Testing Platform diagnostic logs, which are enabled via
the --diagnostic switch.
RunnerSwitch
Gets a value which indicates a runner switch which can be used
to explicitly enable the runner. If the return value is null,
then the reported can only be environmentally enabled (implicitly).
This value is used either as a command line switch (with the console or
.NET CLI runner) or as a runner configuration value (with the MSBuild runner).
string? RunnerSwitch { get; }
Property Value
Remarks
Runner switches are only used in xUnit.net native CLI mode. When Microsoft Testing Platform CLI mode is enabled, reporters are only supported via environmental enablement, since MTP generally controls all the normal output.
Methods
CreateMessageHandler(IRunnerLogger, IMessageSink?)
Creates a message handler that will report messages for the given test assembly.
ValueTask<IRunnerReporterMessageHandler> CreateMessageHandler(IRunnerLogger logger, IMessageSink? diagnosticMessageSink)
Parameters
loggerIRunnerLoggerThe logger used to send result messages to
diagnosticMessageSinkIMessageSinkAn optional message sink that diagnostic messages can be sent to.
Returns
- ValueTask<IRunnerReporterMessageHandler>
The message handler that handles the messages