Skip to content

xUnit outputs: Add timestamp attribute for testsuite elements #4074

Closed

Description

@aaltat

Python junitparser expects that there is timestamp attribute testsuite element.

Also Pytest puts timestamp attribute testsuite element. Example Pytest has:
<testsuite name="pytest" errors="0" failures="0" skipped="2" tests="46" time="18.169" timestamp="2021-09-01T04:43:16.364650" hostname="something">

In Robot Framework there is: <testsuite name="Test" tests="435" errors="0" failures="4" skipped="0" time="244.974">

Is somewhat related to: #2982 and #3944

Activity

  1. added this to the v5.0 milestone on Sep 1, 2021
  2. pekkaklarck commented on Sep 2, 2021

    @pekkaklarck
    Member

    This is definitely a valid enhancement. Having timestamps sounds like a good idea in general and being compatible with the junitparser module is important on its own right as well. Probably should enhance the current tests to use junitparser to make sure we stay compatible. The main problem with all xunit output enhancements is that there's no official schema for that format. Using junitparser a reference is a good idea in that sense as well.

    This needs to be implemented together with #2982 and should also look at #3944 at the same time.

  3. rikerfi commented on Oct 31, 2021

    @rikerfi
    Contributor

    Hi, I would like to give a try for this one as well as #2982

  4. pekkaklarck commented on Nov 1, 2021

    @pekkaklarck
    Member

    Great, go ahead!

  5. rikerfi commented on Nov 1, 2021

    @rikerfi
    Contributor

    Seems that output.xml file is 'single source of truth' for xunit output file as well. Timestamp attribute could be parsed relatively easy from testsuite's starttime. That leads implementation options to consider:

    1. We just 1:1 convert timestamp from testsuite's starttime. E.g. 20211101 10:02:24.107 becomes 2021-11-01T10:02:24.107
    2. Adjust timestamp to isoformat precision rounded e.g. 20211101 10:02:24.107 becomes 2021-11-01T10:02:24.107000
    3. We'll re-format output.xml starttime/endtime having full precision e.g. 20211101 10:02:24.107123 becomes 2021-11-01T10:02:24.107123
    4. Something else?

    I am not sure how breaking change option 3 is. Options 1 & 2 are Robot Framework 'flavors' anyway. So, I would keep compatibility to junitparser and choose option 2.

    Comments welcome!

  6. aaltat commented on Nov 1, 2021

    @aaltat
    ContributorAuthor

    I don't have strong opinion, but option 2 feels best.

  7. pekkaklarck commented on Nov 2, 2021

    @pekkaklarck
    Member

    Compatibility with junitparser is very important so option 2 is clearly the best.

    Changing output.xml timestamp format is a subject of a different issue. I doubt times below milliseconds really matter in acceptance testing (there's e.g. overhead by the framework itself), but we should at least consider switching to ISO 8601 format. I'd like to change how times are handled internally as well, but I doubt that's important enough to make it into RF 5.0.

  8. ra100 commented on Nov 8, 2021

    @ra100

    I'd prefer ISO 8601, but any parseable timestamp would be fine for me, as we just started to look a the xunit report, and were kinda surprised, that timestamp was not included at all. We'd appreciate this feature, as quite important for reporting purposes.

  9. pekkaklarck commented on Nov 16, 2021

    @pekkaklarck
    Member

    As I commented #4144, we need to decide how to handle suites not containing start time. Typically suites have it, but at least when combining results with rebot the root suite doesn't. I believe alternatives are not having timestamp at all or having timestamp=''. I'd prefer the former because it makes it explicit you need to handle that case separately, but I guess always having a timestamp has its benefits as well.

    I already tested that junitparser doesn't actually require the timestamp attribute. It can parse our current xunit.xml file just fine and the resulting TestSuite.timestamp will be None.

  10. added
    acknowledge
    on Nov 29, 2021
  11. pekkaklarck commented on Nov 29, 2021

    @pekkaklarck
    Member

    Implemented in PR #4144 by @rikerfi. Thanks for contribution!

  12. changed the title [-]Add timestamp attribute testsuite element in xunit output[/-] [+]xUnit outputs: Add `timestamp` attribute for `testsuite` elements[/+] on Mar 22, 2022
  13. added a commit that references this issue on Jul 15, 2025
    6f59489
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acknowledgealpha 1good first issuepriority: medium

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions