From 36ec2ba06cc9e2f0f040a59d1b08dc0af5aa59f1 Mon Sep 17 00:00:00 2001 From: Michael J Conrad <32316111+Siphonophora@users.noreply.github.com> Date: Sat, 18 Mar 2023 14:37:21 -0400 Subject: [PATCH 1/8] temporarily depend on local testlogger --- .../Xunit.Xml.TestLogger.TestAdapter.csproj | 5 ++++- src/Xunit.Xml.TestLogger/Xunit.Xml.TestLogger.csproj | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Xunit.Xml.TestLogger.TestAdapter/Xunit.Xml.TestLogger.TestAdapter.csproj b/src/Xunit.Xml.TestLogger.TestAdapter/Xunit.Xml.TestLogger.TestAdapter.csproj index 503e5c6..7ac2d88 100644 --- a/src/Xunit.Xml.TestLogger.TestAdapter/Xunit.Xml.TestLogger.TestAdapter.csproj +++ b/src/Xunit.Xml.TestLogger.TestAdapter/Xunit.Xml.TestLogger.TestAdapter.csproj @@ -26,7 +26,10 @@ - + + + + diff --git a/src/Xunit.Xml.TestLogger/Xunit.Xml.TestLogger.csproj b/src/Xunit.Xml.TestLogger/Xunit.Xml.TestLogger.csproj index 693d6a4..931abe3 100644 --- a/src/Xunit.Xml.TestLogger/Xunit.Xml.TestLogger.csproj +++ b/src/Xunit.Xml.TestLogger/Xunit.Xml.TestLogger.csproj @@ -18,8 +18,10 @@ - + + + From 15787101c353af4a2b3dcb84cf6f1550dc2ea818 Mon Sep 17 00:00:00 2001 From: Michael J Conrad <32316111+Siphonophora@users.noreply.github.com> Date: Sat, 18 Mar 2023 15:10:56 -0400 Subject: [PATCH 2/8] Add xml sanitizier --- src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs b/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs index df7eb2f..8a71364 100644 --- a/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs +++ b/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs @@ -39,6 +39,8 @@ public class XunitXmlSerializer : ITestResultSerializer { "Test Method Cleanup Failure", "test-method-cleanup" } }; + public IInputSanitizer InputSanitizer { get; } = new InputSanitizerXml(); + public string Serialize( LoggerConfiguration loggerConfiguration, TestRunConfiguration runConfiguration, From 25b380991b3102ce1a2fcaee3adb8a6e6cb4ffdd Mon Sep 17 00:00:00 2001 From: Michael J Conrad <32316111+Siphonophora@users.noreply.github.com> Date: Sat, 18 Mar 2023 15:15:11 -0400 Subject: [PATCH 3/8] Remove old xml sanitizier --- src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs b/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs index 8a71364..73eac2b 100644 --- a/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs +++ b/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs @@ -169,8 +169,8 @@ private static XElement CreateErrorElement(TestResultInfo result) private static XElement CreateFailureElement(string exceptionType, string message, string stackTrace) { XElement failureElement = new XElement("failure", new XAttribute("exception-type", exceptionType)); - failureElement.Add(new XElement("message", message.ReplaceInvalidXmlChar())); - failureElement.Add(new XElement("stack-trace", stackTrace.ReplaceInvalidXmlChar())); + failureElement.Add(new XElement("message", message)); + failureElement.Add(new XElement("stack-trace", stackTrace)); return failureElement; } @@ -251,7 +251,7 @@ private static XElement CreateTestElement(TestResultInfo result) { var element = new XElement( "test", - new XAttribute("name", result.TestCase.DisplayName.ReplaceInvalidXmlChar()), + new XAttribute("name", result.TestCase.DisplayName), new XAttribute("type", result.FullTypeName), new XAttribute("method", result.Method), new XAttribute("time", result.Duration.TotalSeconds.ToString("F7", CultureInfo.InvariantCulture)), @@ -267,13 +267,13 @@ private static XElement CreateTestElement(TestResultInfo result) else if (m.Category == "skipReason") { // Using the self-defined category skipReason for now - element.Add(new XElement("reason", new XCData(m.Text.ReplaceInvalidXmlChar()))); + element.Add(new XElement("reason", new XCData(m.Text))); } } if (!string.IsNullOrWhiteSpace(stdOut.ToString())) { - element.Add(new XElement("output", stdOut.ToString().ReplaceInvalidXmlChar())); + element.Add(new XElement("output", stdOut.ToString())); } var fileName = result.TestCase.CodeFilePath; @@ -287,8 +287,8 @@ private static XElement CreateTestElement(TestResultInfo result) { element.Add(new XElement( "failure", - new XElement("message", result.ErrorMessage.ReplaceInvalidXmlChar()), - new XElement("stack-trace", result.ErrorStackTrace.ReplaceInvalidXmlChar()))); + new XElement("message", result.ErrorMessage), + new XElement("stack-trace", result.ErrorStackTrace))); } if (result.TestCase.Traits != null) From 2f2ea15c9d761a684c2215c94e2460c9a8494375 Mon Sep 17 00:00:00 2001 From: Michael J Conrad <32316111+Siphonophora@users.noreply.github.com> Date: Sat, 18 Mar 2023 15:17:35 -0400 Subject: [PATCH 4/8] Use new Traits property from same source --- src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs b/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs index 73eac2b..7e855cb 100644 --- a/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs +++ b/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs @@ -291,9 +291,9 @@ private static XElement CreateTestElement(TestResultInfo result) new XElement("stack-trace", result.ErrorStackTrace))); } - if (result.TestCase.Traits != null) + if (result.Traits != null) { - var traits = from trait in result.TestCase.Traits + var traits = from trait in result.Traits select new XElement("trait", new XAttribute("name", trait.Name), new XAttribute("value", trait.Value)); element.Add(new XElement("traits", traits)); } From 630858108e9823636535365e3a3daffac48c38dc Mon Sep 17 00:00:00 2001 From: Michael J Conrad <32316111+Siphonophora@users.noreply.github.com> Date: Sat, 18 Mar 2023 15:30:22 -0400 Subject: [PATCH 5/8] Use new property for display name --- src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs b/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs index 7e855cb..7040fc7 100644 --- a/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs +++ b/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs @@ -251,7 +251,7 @@ private static XElement CreateTestElement(TestResultInfo result) { var element = new XElement( "test", - new XAttribute("name", result.TestCase.DisplayName), + new XAttribute("name", result.TestCaseDisplayName), new XAttribute("type", result.FullTypeName), new XAttribute("method", result.Method), new XAttribute("time", result.Duration.TotalSeconds.ToString("F7", CultureInfo.InvariantCulture)), From 3c08afa98bccf18cfabab21ee7b2a81f127d003f Mon Sep 17 00:00:00 2001 From: Michael J Conrad <32316111+Siphonophora@users.noreply.github.com> Date: Sat, 18 Mar 2023 15:35:04 -0400 Subject: [PATCH 6/8] Use new properties --- src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs b/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs index 7040fc7..f4379ad 100644 --- a/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs +++ b/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs @@ -276,11 +276,11 @@ private static XElement CreateTestElement(TestResultInfo result) element.Add(new XElement("output", stdOut.ToString())); } - var fileName = result.TestCase.CodeFilePath; + var fileName = result.CodeFilePath; if (!string.IsNullOrWhiteSpace(fileName)) { element.Add(new XElement("source-file", fileName)); - element.Add(new XElement("source-line", result.TestCase.LineNumber)); + element.Add(new XElement("source-line", result.LineNumber)); } if (result.Outcome == TestOutcome.Failed) From bf5ccf8070776c880f87fa012d58875e1511bc5f Mon Sep 17 00:00:00 2001 From: Michael J Conrad <32316111+Siphonophora@users.noreply.github.com> Date: Sat, 18 Mar 2023 16:15:55 -0400 Subject: [PATCH 7/8] Use the method instead of display name --- src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs b/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs index f4379ad..a6145ad 100644 --- a/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs +++ b/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs @@ -251,7 +251,7 @@ private static XElement CreateTestElement(TestResultInfo result) { var element = new XElement( "test", - new XAttribute("name", result.TestCaseDisplayName), + new XAttribute("name", result.Method), new XAttribute("type", result.FullTypeName), new XAttribute("method", result.Method), new XAttribute("time", result.Duration.TotalSeconds.ToString("F7", CultureInfo.InvariantCulture)), From 2b631106ae50e5c926d4b6559a58c312ed95ca1f Mon Sep 17 00:00:00 2001 From: Arun Mahapatra Date: Wed, 5 Jul 2023 10:45:35 +0530 Subject: [PATCH 8/8] fix: use DisplayName for test case name in logs. --- scripts/dependencies.props | 2 +- .../Xunit.Xml.TestLogger.TestAdapter.csproj | 4 +--- src/Xunit.Xml.TestLogger/Xunit.Xml.TestLogger.csproj | 4 +--- src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs | 2 +- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/scripts/dependencies.props b/scripts/dependencies.props index c7142c8..a4e432c 100644 --- a/scripts/dependencies.props +++ b/scripts/dependencies.props @@ -4,7 +4,7 @@ 1.3.2 15.7.2 4.9.0 - 3.0.86 + 3.0.122 15.5.0 diff --git a/src/Xunit.Xml.TestLogger.TestAdapter/Xunit.Xml.TestLogger.TestAdapter.csproj b/src/Xunit.Xml.TestLogger.TestAdapter/Xunit.Xml.TestLogger.TestAdapter.csproj index 7ac2d88..d4cdf6c 100644 --- a/src/Xunit.Xml.TestLogger.TestAdapter/Xunit.Xml.TestLogger.TestAdapter.csproj +++ b/src/Xunit.Xml.TestLogger.TestAdapter/Xunit.Xml.TestLogger.TestAdapter.csproj @@ -26,10 +26,8 @@ + - - - diff --git a/src/Xunit.Xml.TestLogger/Xunit.Xml.TestLogger.csproj b/src/Xunit.Xml.TestLogger/Xunit.Xml.TestLogger.csproj index 931abe3..693d6a4 100644 --- a/src/Xunit.Xml.TestLogger/Xunit.Xml.TestLogger.csproj +++ b/src/Xunit.Xml.TestLogger/Xunit.Xml.TestLogger.csproj @@ -18,10 +18,8 @@ + - - - diff --git a/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs b/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs index a6145ad..740fba6 100644 --- a/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs +++ b/src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs @@ -251,7 +251,7 @@ private static XElement CreateTestElement(TestResultInfo result) { var element = new XElement( "test", - new XAttribute("name", result.Method), + new XAttribute("name", result.DisplayName), new XAttribute("type", result.FullTypeName), new XAttribute("method", result.Method), new XAttribute("time", result.Duration.TotalSeconds.ToString("F7", CultureInfo.InvariantCulture)),