<PackageReference Include="NUnit" Version="4.2.1" />

TestOutput

public class TestOutput
The TestOutput class holds a unit of output from a test to a specific output stream
using System.IO; using System.Runtime.CompilerServices; using System.Xml; namespace NUnit.Framework.Interfaces { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] public class TestOutput { public string Text { get; } public string Stream { get; } [System.Runtime.CompilerServices.Nullable(2)] [field: System.Runtime.CompilerServices.Nullable(2)] public string TestName { [System.Runtime.CompilerServices.NullableContext(2)] get; } [System.Runtime.CompilerServices.Nullable(2)] [field: System.Runtime.CompilerServices.Nullable(2)] public string TestId { [System.Runtime.CompilerServices.NullableContext(2)] get; } public TestOutput(string text, string stream, [System.Runtime.CompilerServices.Nullable(2)] string testId, [System.Runtime.CompilerServices.Nullable(2)] string testName) { Guard.ArgumentNotNull(text, "text"); Guard.ArgumentNotNull(stream, "stream"); Text = text; Stream = stream; TestId = testId; TestName = testName; } public override string ToString() { return Stream + ": " + Text; } public string ToXml() { using (StringWriter stringWriter = new StringWriter()) { using (XmlWriter writer = XmlWriter.Create(stringWriter, XmlExtensions.FragmentWriterSettings)) ToXml(writer); return stringWriter.ToString(); } } internal void ToXml(XmlWriter writer) { writer.WriteStartElement("test-output"); writer.WriteAttributeString("stream", Stream); if (TestId != null) writer.WriteAttributeString("testid", TestId); if (TestName != null) writer.WriteAttributeStringSafe("testname", TestName); writer.WriteCDataSafe(Text); writer.WriteEndElement(); } } }