Skip to content

Commit

Permalink
NET-881 Log debug message on failed test mapping in XmlTestReportParser
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-meseldzija-sonarsource authored and sonartech committed Dec 17, 2024
1 parent 00ecc1e commit 852b0ee
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void parse(Map<String, Consumer<XmlParserHelper>> 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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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<String> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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<String> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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<String> 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
Expand Down

0 comments on commit 852b0ee

Please sign in to comment.