Menu

#14 Test run order incorrect in 24-hour time zone

v1.3.1
open
nobody
None
5
2017-03-06
2016-12-03
No

Hi!

First things first: I love UnitTH, great tool!

I came across a bug concerning the time of execution in the 'Exec date' field. I live in Europe and we use the 24-hour format instead of AM/PM.

The time of execution is displayed in AM/PM (but without the affix AM/PM). This results in wrong ordering of the test runs. When I run a test in the morning and later that day in the afternoon, the test that ran in the morning is being displayed as most recent test run. The various generated graphs are also displaying test runs in the wrong order.

Could you implement a 24 hour notation? And display the test runs and graphs in the right order?

Steps to reproduce:
1. Set your system clock to a 24-hour time zone/notation.
2. Run a test in the morning (AM).
3. Run a test in the afternoon (PM).
4. Gerenate a report.
5. The test that ran in the morning is being displayed as the most recent test run. The various graphs display the morning test also as the most recent test run.

See the attachment which displays the incorrect order of test runs.

Thanks! Greatly appreciated :)

1 Attachments

Discussion

  • Sander Roosdorp

    Sander Roosdorp - 2016-12-03

    I forgot; some extra information about my Java version and time zone settings.

    > java -version
    Picked up _JAVA_OPTIONS: -XX:+ForceTimeHighResolution -Dsun.java2d.noddraw=true -Duser.timezone='Europe/Amsterdam'
    java version "1.8.0_111"
    Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
    Java HotSpot(TM) Client VM (build 25.111-b14, mixed mode)
    

    Thanks :)

     
  • Andreas Nyberg

    Andreas Nyberg - 2016-12-05

    Confirmed, thanks for submitting a report, thougt this tool was dead and buried since long as the same functionality is present in many modern build server. Got it though, it has the wrong locale when parsing and I could easily fix this I think, even if it mean picking up how to learn Subversion all over again.

    If you are using Jenkins by anyway someone cloned UnitTH there as a Test Report Analyzer plugin so please use that one.

     
    • Sander Roosdorp

      Sander Roosdorp - 2016-12-05

      I'm using UnitTH in conjunction with SoapUI (Open Source, I'm aware the paid version has more advanced reporting on it self). Unfortunately right now it's not possible for me to use the SoapUI tests in a build server. Not because of a technical limitation, but because of some restrictions in my organization. Also they use Atlassian Bamboo (which does have a SoapUI plugin, but I can't use it right now because of the organizational restrictions) instead of Jenkins. I didn't want to deploy my own Jenkins build server e.g. continuous integration environment. It would be way too much for my needs.

      What I did is I put together SoapUI and UnitTH with some batch scripting to create my own little 'automated testing street'. It automates the execution of SoapUI tests and generating of (historical) reports, but nothing more than that. I'm very happy with it. For me this combination (SoapUI Open Source and UnitTH) is a little gem :)

      So if you could fix it I greatly appreciate it!

      Thanks :)

       
  • Andreas Nyberg

    Andreas Nyberg - 2016-12-05

    Fair enough, I'll give it a shot during the week. It's been many years since I touched the code the last time.

    Running on Bamboo should not be too big if an issue if you wrap your SoapUI project file in JUnit tests. Wrote a small piece on that some years ago, have a go at it as a learning example. https://technicaltesting.wordpress.com/2011/05/11/datadriven-soapui-junit-integration-with-readable-test-reports/

    Cheers!

     
  • Sander Roosdorp

    Sander Roosdorp - 2016-12-05

    Great! And thanks for the tip on Bamboo, will have a look further into it :)

     
  • Sander Roosdorp

    Sander Roosdorp - 2017-01-09

    Hope you had great holidays!

    Did you have the time to take a look into it? :)

     
  • Andreas Nyberg

    Andreas Nyberg - 2017-01-10

    Tried to pin-point the place where things went wrong earlier. Can you pls post a snippet of a TEST-...xml file so that I can check the format of the date stamp in the 'timestamp' element.

     
  • Sander Roosdorp

    Sander Roosdorp - 2017-01-10

    In the attachment you can find a TEST-..xml which SoapUI generates (I anonymized some things like testcase names). The timestamp element is absent.

    Maybe this is the issue? The timestamp element is absent and UnitTH falls back to AM/PM format (but without showing AM/PM in the 'Exec date' field and the various graphs).

     

    Last edit: Sander Roosdorp 2019-12-10
  • Sander Roosdorp

    Sander Roosdorp - 2017-01-20

    Hi Andreas!

    So I fiddled around a bit to get UnitTH display the correct Exec date. I found out that the absence of the timestamp element in the JUnit XML report causes this issue.

    The xml file posted above does not contain a timestamp (SoapUI doesn't generate it apparently):

    <testsuite name="Anonymous TestSuite" tests="15" failures="0" errors="0" time="12.841">
    

    So I added a timestamp in the example file like this:

    <testsuite name="Anonymous TestSuite" tests="15" failures="0" errors="0" time="12.841" timestamp="2017-01-01T17:30:45">
    

    When I generate a report based on the second (attached) xml file it does show the Exec date in 24H notation format (see screenshot in attachment).

    I guess UnitTH falls back to the date/time of the report generation if the JUnit XML file doesn't contain a timestamp? And this fallback is using the US locale? I saw this in the code of UnitTH.java:

            // We are using the US locale to keep all date and double formats
            // the same wherever we go.
            Locale.setDefault(Locale.US);
    

    Only the Exec date field (and generation of the various graphs) doesn't consider the AM/PM affix.

    Maybe this helps you a bit :)

    Thanks again!

     

    Last edit: Sander Roosdorp 2019-12-10
  • Sander Roosdorp

    Sander Roosdorp - 2017-03-06

    Hi Andreas!

    Wanted to give a little update. I made a little workaround with a tool called XMLStarlet. This tool allows editing of XML based on XPath.

    With this tool I'm adding a timestamp attribute containing the current datetime in ISO8601 format (YYYY-MM-DDTHH:MM:SS) to the 'testsuite' element in the JUnit XML file which SoapUI produces after running the tests. This fixes my issue because if there is a valid timestamp in the JUnit XML file UnitTH will use this one instead of generating one on its own based on the current system date (see also my last post).

    I extended my batch file with the following (can come in handy for people who encounter this issue)

    SETLOCAL ENABLEDELAYEDEXPANSION
    
    SET isodtwithhyphen=%date:~9,4%-%date:~6,2%-%date:~3,2%T%time:~0,2%:%time:~3,2%:%time:~6,2%
    SET isodtwithhyphen=%isodtwithhyphen: =0%
    
    FOR %%F IN (.\log\TEST-*.xml) DO (
    xml.exe ed -a /testsuite -t attr -n timestamp -v %isodtwithhyphen% %%F > .\log\timestamped\%%~nxF
    )
    

    The xml.exe file is XMLStarlet and can be downloaded from http://xmlstar.sourceforge.net/

     

    Last edit: Sander Roosdorp 2019-12-10

Log in to post a comment.