diff --git a/src/NUnitTestAdapter/NUnitEventListener.cs b/src/NUnitTestAdapter/NUnitEventListener.cs index f483875c..1d66ef2c 100644 --- a/src/NUnitTestAdapter/NUnitEventListener.cs +++ b/src/NUnitTestAdapter/NUnitEventListener.cs @@ -239,7 +239,11 @@ public void TestOutput(INUnitTestEventTestOutput outputNodeEvent) outputNodes.Add(outputNodeEvent); } - recorder.SendMessage(TestMessageLevel.Warning, text); + var testMessageLevel = outputNodeEvent.IsErrorStream + ? TestMessageLevel.Warning + : TestMessageLevel.Informational; + + recorder.SendMessage(testMessageLevel, text); } } } diff --git a/src/NUnitTestAdapterTests/NUnitEventListenerTests.cs b/src/NUnitTestAdapterTests/NUnitEventListenerTests.cs index 12f3c72c..2a4e531a 100644 --- a/src/NUnitTestAdapterTests/NUnitEventListenerTests.cs +++ b/src/NUnitTestAdapterTests/NUnitEventListenerTests.cs @@ -139,6 +139,7 @@ public void TestFinished_CallsRecordResultCorrectly() VerifyTestResult(testLog.Events[1].TestResult); } + // [TestCase(ResultState.Success, TestOutcome.Passed, null)] // [TestCase(ResultState.Failure, TestOutcome.Failed, "My failure message")] // [TestCase(ResultState.Error, TestOutcome.Failed, "Error!")] @@ -166,6 +167,25 @@ public void TestFinished_CallsRecordResultCorrectly() #endregion + #region TestOutput Tests + + [TestCase(NUnitTestEventTestOutput.Streams.Error, TestMessageLevel.Warning, TestName = "TestOutput with 'Error' stream is send as message level Warning")] + [TestCase(NUnitTestEventTestOutput.Streams.Progress, TestMessageLevel.Informational, TestName = "TestOutput with 'Progress' stream is send as message level Informational")] + [TestCase(NUnitTestEventTestOutput.Streams.NoIdea, TestMessageLevel.Informational, TestName = "TestOutput with 'NoIdea' stream is send as message level Informational")] + public void TestOutput_SendsMessageWithCorrectMessageLevel(NUnitTestEventTestOutput.Streams streamType, TestMessageLevel expectedTestMessageLevel) + { + var outPutXml = @$""; + var testOutput = new NUnitTestEventTestOutput(XmlHelper.CreateXmlNode(outPutXml)); + + listener.TestOutput(testOutput); + Assume.That(testLog.Events.Count, Is.EqualTo(1)); + Assume.That(testLog.Events[0].EventType, Is.EqualTo(FakeFrameworkHandle.EventType.SendMessage)); + + Assert.That(testLog.Events[0].Message.Level, Is.EqualTo(expectedTestMessageLevel)); + } + + #endregion + #region Listener Lifetime Tests #if NET35 [Test]