From 852b0eebe982af396d1eaf3e334ae53c123e2b29 Mon Sep 17 00:00:00 2001 From: Alex Meseldzija Date: Mon, 16 Dec 2024 10:38:54 +0100 Subject: [PATCH] NET-881 Log debug message on failed test mapping in XmlTestReportParser --- .../org/sonar/plugins/dotnet/tests/XmlTestReportParser.java | 2 +- .../plugins/dotnet/tests/NUnitTestResultsParserTest.java | 6 +++--- .../dotnet/tests/VisualStudioTestResultParserTest.java | 6 +++--- .../plugins/dotnet/tests/XUnitTestResultParserTest.java | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sonar-dotnet-core/src/main/java/org/sonar/plugins/dotnet/tests/XmlTestReportParser.java b/sonar-dotnet-core/src/main/java/org/sonar/plugins/dotnet/tests/XmlTestReportParser.java index 985901ea5f1..c4c607d739b 100644 --- a/sonar-dotnet-core/src/main/java/org/sonar/plugins/dotnet/tests/XmlTestReportParser.java +++ b/sonar-dotnet-core/src/main/java/org/sonar/plugins/dotnet/tests/XmlTestReportParser.java @@ -55,7 +55,7 @@ public void parse(Map> tagHandlers) { protected void addTestResultToFile(String methodFullName, UnitTestResults testResults) { if(!methodFileMap.containsKey(methodFullName)) { - LOG.warn("Test method {} cannot be mapped to the test source file. The test will not be included.", methodFullName); + LOG.debug("Test method {} cannot be mapped to the test source file. The test will not be included.", methodFullName); return; } diff --git a/sonar-dotnet-core/src/test/java/org/sonar/plugins/dotnet/tests/NUnitTestResultsParserTest.java b/sonar-dotnet-core/src/test/java/org/sonar/plugins/dotnet/tests/NUnitTestResultsParserTest.java index b3dcf8951cf..4d96da447c3 100644 --- a/sonar-dotnet-core/src/test/java/org/sonar/plugins/dotnet/tests/NUnitTestResultsParserTest.java +++ b/sonar-dotnet-core/src/test/java/org/sonar/plugins/dotnet/tests/NUnitTestResultsParserTest.java @@ -244,9 +244,9 @@ public void test_name_not_mapped() { sut.parse(file, new HashMap<>(), Map.of("Some.Other.TestMethod", "C:\\dev\\Playground\\NUnit.Test\\Sample.cs")); - List warnLogs = logTester.logs(Level.WARN); - assertThat(warnLogs).hasSize(1); - assertThat(warnLogs.get(0)).isEqualTo("Test method NUnitTestProj.NUnitTestProject.UnitTest1.TestMethodDoesNotExist cannot be mapped to the test source file. The test will not be included."); + List debugLogs = logTester.logs(Level.DEBUG); + assertThat(debugLogs).hasSize(2); + assertThat(debugLogs.get(1)).isEqualTo("Test method NUnitTestProj.NUnitTestProject.UnitTest1.TestMethodDoesNotExist cannot be mapped to the test source file. The test will not be included."); } @Test diff --git a/sonar-dotnet-core/src/test/java/org/sonar/plugins/dotnet/tests/VisualStudioTestResultParserTest.java b/sonar-dotnet-core/src/test/java/org/sonar/plugins/dotnet/tests/VisualStudioTestResultParserTest.java index 3cbd51f4578..e46b8e32057 100644 --- a/sonar-dotnet-core/src/test/java/org/sonar/plugins/dotnet/tests/VisualStudioTestResultParserTest.java +++ b/sonar-dotnet-core/src/test/java/org/sonar/plugins/dotnet/tests/VisualStudioTestResultParserTest.java @@ -128,9 +128,9 @@ public void test_name_not_mapped() { sut.parse(file, new HashMap<>(), Map.of("Some.Other.TestMethod", "C:\\dev\\Playground\\NUnit.Test\\Sample.cs")); - List warnLogs = logTester.logs(Level.WARN); - assertThat(warnLogs).hasSize(1); - assertThat(warnLogs.get(0)).isEqualTo("Test method Playground.Test.TestProject1.UnitTest1.TestShouldFail cannot be mapped to the test source file. The test will not be included."); + List debugLogs = logTester.logs(Level.DEBUG); + assertThat(debugLogs).hasSize(2); + assertThat(debugLogs.get(1)).isEqualTo("Test method Playground.Test.TestProject1.UnitTest1.TestShouldFail cannot be mapped to the test source file. The test will not be included."); } @Test diff --git a/sonar-dotnet-core/src/test/java/org/sonar/plugins/dotnet/tests/XUnitTestResultParserTest.java b/sonar-dotnet-core/src/test/java/org/sonar/plugins/dotnet/tests/XUnitTestResultParserTest.java index d456fda115c..172dcc6f617 100644 --- a/sonar-dotnet-core/src/test/java/org/sonar/plugins/dotnet/tests/XUnitTestResultParserTest.java +++ b/sonar-dotnet-core/src/test/java/org/sonar/plugins/dotnet/tests/XUnitTestResultParserTest.java @@ -244,9 +244,9 @@ public void test_name_not_mapped() { sut.parse(file, new HashMap<>(), Map.of("Some.Other.TestMethod", "C:\\dev\\Playground\\XUnit.Test\\Sample.cs")); - List warnLogs = logTester.logs(Level.WARN); - assertThat(warnLogs).hasSize(1); - assertThat(warnLogs.get(0)).isEqualTo("Test method XUnitTestProj.XUnitTestProject1.UnitTest1.TestMethodDoesNotExist cannot be mapped to the test source file. The test will not be included."); + List debugLogs = logTester.logs(Level.DEBUG); + assertThat(debugLogs).hasSize(2); + assertThat(debugLogs.get(1)).isEqualTo("Test method XUnitTestProj.XUnitTestProject1.UnitTest1.TestMethodDoesNotExist cannot be mapped to the test source file. The test will not be included."); } @Test