Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-71769

testsuite time SUREFIRE_TIME is not same as xs:decimal

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Minor Minor
    • xunit-plugin
    • None

      The junit-10.xsd specifies the SUREFIRE_TIME to use the ',' as decimal separator. However the https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd schema specifies this a s"xs:decimal" which is using '.' as decimal separator.

       

      This mismatch causes valid JUnit XMLs to be rejected by the plugin.

          [JENKINS-71769] testsuite time SUREFIRE_TIME is not same as xs:decimal

          Nikolas Falco added a comment - - edited

          that schema is a mix of both Ant and Maven Surefire schema.

          You link the windyroad that is ant schema (not apache official).

          Nikolas Falco added a comment - - edited that schema is a mix of both Ant and Maven Surefire schema. You link the windyroad that is ant schema (not apache official).

          Nikolas Falco added a comment - - edited

          I go into deep. Ant write time attribute with Double.toString (https://github.com/apache/ant/blob/6f68fbdefad521741b37304cfdfc6d8646cf1839/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java#L265) that internally write number using dot as decimal separator regardless the Locale.

          The XSD in xunit plugin use this pattern:

          (([0-9]{0,3},)*[0-9]{3}|[0-9]{0,3})*(\.[0-9]{0,3})? 

          the comma is used as thousand separator not decimal separator.

           

          So please explain better what is the issue. To help me attach example of input file and the jenkins console log of the error

          Nikolas Falco added a comment - - edited I go into deep. Ant write time attribute with Double.toString ( https://github.com/apache/ant/blob/6f68fbdefad521741b37304cfdfc6d8646cf1839/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java#L265) that internally write number using dot as decimal separator regardless the Locale. The XSD in xunit plugin use this pattern: (([0-9]{0,3},)*[0-9]{3}|[0-9]{0,3})*(\.[0-9]{0,3})? the comma is used as thousand separator not decimal separator.   So please explain better what is the issue. To help me attach example of input file and the jenkins console log of the error

          OK, I found the issue where the schema fails. In my XML the time value has 4 decimal places. The xunit plugin's XSD allows only max 3. The junit plugin parses the same XML without any issues.

          Szabolcs Tolnai added a comment - OK, I found the issue where the schema fails. In my XML the time value has 4 decimal places. The xunit plugin's XSD allows only max 3. The junit plugin parses the same XML without any issues.

          Why was this closed? The value for time should allow more than 3 decimal places. The Ant Double.toString() may output more than 3 decimal places.

          Szabolcs Tolnai added a comment - Why was this closed? The value for time should allow more than 3 decimal places. The Ant Double.toString() may output more than 3 decimal places.

          Nikolas Falco added a comment -

          I closed because supported schema supports only 3 decimal of second (than mean milliseconds precision) by design. Neither Ant nor Maven will never produce time attribute with 4 decimal (that mean fragment of millisecond).

          Just to understand time in Ant (similar to Maven) is calculated using System.currentTimeMillis() and than divided by 1000 because time is expressed in seconds that means result never contains 4 decimal.
          From Ant

          JUnitTestRunner.java
          final long start = System.currentTimeMillis();
          ...
          junitTest.setRunTime(System.currentTimeMillis() - start);
          
          XMLJUnitResultFormatter.java
          rootElement.setAttribute(ATTR_TIME, Double.toString(suite.getRunTime() / ONE_SECOND));
          

          I suppose you are using some tool that declare to produce a JUnit report but use an own custom format. For those case please have a look to the documentation here.
          As explained (long) in other issues I will never support any other kind of JUnit format. To meet this discussion I will close the issue as Won't Fix.

          Nikolas Falco added a comment - I closed because supported schema supports only 3 decimal of second (than mean milliseconds precision) by design . Neither Ant nor Maven will never produce time attribute with 4 decimal (that mean fragment of millisecond). Just to understand time in Ant (similar to Maven) is calculated using System.currentTimeMillis() and than divided by 1000 because time is expressed in seconds that means result never contains 4 decimal. From Ant JUnitTestRunner.java final long start = System .currentTimeMillis(); ... junitTest.setRunTime( System .currentTimeMillis() - start); XMLJUnitResultFormatter.java rootElement.setAttribute(ATTR_TIME, Double .toString(suite.getRunTime() / ONE_SECOND)); I suppose you are using some tool that declare to produce a JUnit report but use an own custom format. For those case please have a look to the documentation here . As explained (long) in other issues I will never support any other kind of JUnit format. To meet this discussion I will close the issue as Won't Fix.

            nfalco Nikolas Falco
            szabi_tolnai Szabolcs Tolnai
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: