diff options
author | Matteo Mara <matteo.mara@sonarsource.com> | 2022-09-21 11:11:06 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-09-22 20:03:32 +0000 |
commit | b8f00f77cec25c628427ec42c39481a0a30ad3f3 (patch) | |
tree | a29c42bd4f76b71c3013851ea084e11d5abe0c7f /sonar-scanner-engine/src | |
parent | a24eb48f4d278c38b363e1fc8d9f13c1dac6b0c4 (diff) | |
download | sonarqube-b8f00f77cec25c628427ec42c39481a0a30ad3f3.tar.gz sonarqube-b8f00f77cec25c628427ec42c39481a0a30ad3f3.zip |
SONAR-17259 Remove unsupported XML tag for generic test execution report
Diffstat (limited to 'sonar-scanner-engine/src')
6 files changed, 7 insertions, 52 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultTestCase.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultTestCase.java index 652cc8999a4..1c133320205 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultTestCase.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultTestCase.java @@ -35,7 +35,6 @@ public class DefaultTestCase { private Long durationInMs; private Status status; private String name; - private String message; public String type() { return type; @@ -75,13 +74,4 @@ public class DefaultTestCase { this.name = s; return this; } - - public String message() { - return message; - } - - public DefaultTestCase setMessage(String s) { - this.message = s; - return this; - } } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericTestExecutionReportParser.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericTestExecutionReportParser.java index 7a56df1cecc..7d9f3c33ec2 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericTestExecutionReportParser.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericTestExecutionReportParser.java @@ -54,8 +54,7 @@ public class GenericTestExecutionReportParser { private static final String NAME_ATTR = "name"; private static final String DURATION_ATTR = "duration"; - private static final String MESSAGE_ATTR = "message"; - public static final String OK = "ok"; + public static final String ERROR = "error"; public static final String FAILURE = "failure"; public static final String SKIPPED = "skipped"; @@ -150,9 +149,6 @@ public class GenericTestExecutionReportParser { } else if (ERROR.equals(elementName)) { status = Status.ERROR; } - if (Status.OK != status) { - testCase.setMessage(mandatoryAttribute(child, MESSAGE_ATTR)); - } } testCase.setStatus(status); diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/deprecated/test/DefaultTestCaseTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/deprecated/test/DefaultTestCaseTest.java index 34deff51b40..b3494029539 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/deprecated/test/DefaultTestCaseTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/deprecated/test/DefaultTestCaseTest.java @@ -29,7 +29,6 @@ public class DefaultTestCaseTest { @Test public void getters_after_setters() { testCase - .setMessage("message") .setName("name") .setType("type") .setDurationInMs(1234L) @@ -39,6 +38,5 @@ public class DefaultTestCaseTest { assertThat(testCase.name()).isEqualTo("name"); assertThat(testCase.type()).isEqualTo("type"); assertThat(testCase.durationInMs()).isEqualTo(1234L); - assertThat(testCase.message()).isEqualTo("message"); } } diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionReportParserTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionReportParserTest.java index bf3818f3aa8..491b0c3ad93 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionReportParserTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionReportParserTest.java @@ -117,34 +117,6 @@ public class GenericTestExecutionReportParserTest { } @Test(expected = MessageException.class) - public void unittest_duration_in_testCase_should_be_a_number() throws Exception { - addFileToFs(setupFile("file1")); - parseUnitTestReport("<unitTest version=\"1\"><file path=\"file1\">" - + "<testCase name=\"test1\" duration=\"aaa\"/></file></unitTest>"); - } - - @Test(expected = MessageException.class) - public void unittest_failure_should_have_a_message() throws Exception { - addFileToFs(setupFile("file1")); - parseUnitTestReport("<unitTest version=\"1\"><file path=\"file1\">" - + "<testCase name=\"test1\" duration=\"2\"><failure /></testCase></file></unitTest>"); - } - - @Test(expected = MessageException.class) - public void unittest_error_should_have_a_message() throws Exception { - addFileToFs(setupFile("file1")); - parseUnitTestReport("<unitTest version=\"1\"><file path=\"file1\">" - + "<testCase name=\"test1\" duration=\"2\"><error /></testCase></file></unitTest>"); - } - - @Test(expected = MessageException.class) - public void unittest_skipped_should_have_a_message() throws Exception { - addFileToFs(setupFile("file1")); - parseUnitTestReport("<unitTest version=\"1\"><file path=\"file1\">" - + "<testCase name=\"test1\" duration=\"2\"><skipped notmessage=\"\"/></testCase></file></unitTest>"); - } - - @Test(expected = MessageException.class) public void unittest_duration_in_testCase_should_not_be_negative() throws Exception { addFileToFs(setupFile("file1")); parseUnitTestReport("<unitTest version=\"1\"><file path=\"file1\">" @@ -187,7 +159,6 @@ public class GenericTestExecutionReportParserTest { DefaultTestCase testCase = mock(DefaultTestCase.class); when(testCase.setDurationInMs(anyLong())).thenReturn(testCase); when(testCase.setStatus(any(DefaultTestCase.Status.class))).thenReturn(testCase); - when(testCase.setMessage(anyString())).thenReturn(testCase); when(testCase.setType(anyString())).thenReturn(testCase); return testCase; } diff --git a/sonar-scanner-engine/src/test/resources/org/sonar/scanner/genericcoverage/unittest.xml b/sonar-scanner-engine/src/test/resources/org/sonar/scanner/genericcoverage/unittest.xml index f1d12ec0f50..597f88698a8 100644 --- a/sonar-scanner-engine/src/test/resources/org/sonar/scanner/genericcoverage/unittest.xml +++ b/sonar-scanner-engine/src/test/resources/org/sonar/scanner/genericcoverage/unittest.xml @@ -3,13 +3,13 @@ <file path="src/main/java/com/example/ClassWithoutBranch.java"> <testCase name="test1" duration="5"/> <testCase name="test2" duration="500"> - <skipped message="short message">other</skipped> + <skipped>other</skipped> </testCase> <testCase name="test3" duration="100"> - <failure message="short">stacktrace</failure> + <failure>stacktrace</failure> </testCase> <testCase name="test4" duration="500"> - <error message="short">stacktrace</error> + <error>stacktrace</error> </testCase> </file> </unitTest> diff --git a/sonar-scanner-engine/src/test/resources/org/sonar/scanner/genericcoverage/unittest2.xml b/sonar-scanner-engine/src/test/resources/org/sonar/scanner/genericcoverage/unittest2.xml index 35ff4ad5912..c1e778ecc73 100644 --- a/sonar-scanner-engine/src/test/resources/org/sonar/scanner/genericcoverage/unittest2.xml +++ b/sonar-scanner-engine/src/test/resources/org/sonar/scanner/genericcoverage/unittest2.xml @@ -2,14 +2,14 @@ <file path="src/main/java/com/example/EmptyClass.java"/> <file path="src/main/java/com/example/ClassWithBranches.java"> <testCase name="test1" duration="500"> - <skipped message="short message">other</skipped> + <skipped>other</skipped> </testCase> <testCase name="test2" duration="300"> - <failure message="short">stacktrace</failure> + <failure>stacktrace</failure> </testCase> <testCase name="test3" duration="300" /> <testCase name="test4" duration="300"> - <ok message="aaa">long</ok> + <ok>long</ok> </testCase> </file> </unitTest> |