]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-17259 Remove unsupported XML tag for generic test execution report
authorMatteo Mara <matteo.mara@sonarsource.com>
Wed, 21 Sep 2022 09:11:06 +0000 (11:11 +0200)
committersonartech <sonartech@sonarsource.com>
Thu, 22 Sep 2022 20:03:32 +0000 (20:03 +0000)
server/sonar-docs/src/pages/analysis/test-coverage/generic-test.md
sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultTestCase.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericTestExecutionReportParser.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/deprecated/test/DefaultTestCaseTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionReportParserTest.java
sonar-scanner-engine/src/test/resources/org/sonar/scanner/genericcoverage/unittest.xml
sonar-scanner-engine/src/test/resources/org/sonar/scanner/genericcoverage/unittest2.xml
sonar-scanner-engine/test-resources/mediumtest/xoo/sample-generic-test-exec/unittest.xml
sonar-scanner-engine/test-resources/mediumtest/xoo/sample-generic-test-exec/unittest2.xml

index 2be01f348139049248552f7fbb1fe4dfe20b0184..a5181791d5edc1e7457624c374223ce2b017450b 100644 (file)
@@ -84,13 +84,13 @@ The supported format looks like this:
   <file path="testx/ClassOneTest.xoo">
        <testCase name="test1" duration="5"/>
        <testCase name="test2" duration="500">
-         <skipped message="short message"/>
+         <skipped/>
        </testCase>
        <testCase name="test3" duration="100">
-         <failure message="short"/>
+         <failure/>
        </testCase>
        <testCase name="test4" duration="500">
-         <error message="short"/>
+         <error/>
        </testCase>
   </file>
 </testExecutions>
@@ -110,5 +110,4 @@ It can have the following attributes/children:
 * `testCase` (mandatory)
   * `name` (mandatory): name of the test case
   * `duration` (mandatory): long value in milliseconds
-  * `failure|error|skipped` (optional): if the test is not OK, report the cause with a message.
-    * `message` (mandatory): short message describing the cause. This attribute is mandatory but not displayed in the UI.
\ No newline at end of file
+  * `failure|error|skipped` (optional): if the test is not OK, report its status.
index 652cc8999a4757a046aefbb7154b4a96556af36f..1c1333202058dd7f395deb55b0af58c225f666b4 100644 (file)
@@ -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;
-  }
 }
index 7a56df1cecc5f921b655bd0535376e667d61190c..7d9f3c33ec2eda9bc1fbddf885f99086f158161f 100644 (file)
@@ -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);
 
index 34deff51b400fdea8e493b7d3b3cd036cd93f104..b3494029539472fc26d210759cdbcf2bd55609c6 100644 (file)
@@ -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");
   }
 }
index bf3818f3aa8ab5b4a45061d2b1ebc30beb65ec18..491b0c3ad932d1aa1664633f51b7b9ed0f1d0c8c 100644 (file)
@@ -116,34 +116,6 @@ public class GenericTestExecutionReportParserTest {
     parseUnitTestReport("<unitTest version=\"2\"></unitTest>");
   }
 
-  @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"));
@@ -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;
   }
index f1d12ec0f50c5229163c39231ee5e761480f873d..597f88698a8ed9c955f7a268c6cc083401b62ec4 100644 (file)
@@ -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>
index 35ff4ad59120a86dda223f2f5f0626fcf749e143..c1e778ecc734e855a4210b7bb683fcf92f23d624 100644 (file)
@@ -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>
index a29747422b9413da33e7a79bc6358bcfee07ce1a..8e3b8ecdc2aee0fbf6312c111ed723e82ed88ed2 100644 (file)
@@ -2,13 +2,13 @@
   <file path="testx/ClassOneTest.xoo">
     <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>
 </testExecutions>
index 203444d514d8c1fa6be5f60a90e29e831848c3e7..09d01113c9e04ef1f396cad4674372322a6f73c0 100644 (file)
@@ -2,7 +2,7 @@
   <file path="testx/ClassOneTest.xoo">
     <testCase name="test1b" duration="5"/>
     <testCase name="test2" duration="500">
-      <skipped message="short message">other</skipped>
+      <skipped>other</skipped>
     </testCase>
   </file>
 </testExecutions>