-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timestamp in Pytest JUnit XML test report doesn't have time zone infomation #7662
Comments
I think it would be appropriate to always use UTC, and to include the timezone (i.e. utc) in the xml file. https://blog.ganssle.io/articles/2019/11/utcnow.html has some good advice on the topic. |
Local time with zone and UTC offset is probably the most useful. It's just
whether or not JUnit supports it
…On Thu, Aug 20, 2020, 04:47 Zac Hatfield-Dodds ***@***.***> wrote:
I think it would be appropriate to always use UTC, and to include the
timezone (i.e. utc) in the xml file.
https://blog.ganssle.io/articles/2019/11/utcnow.html has some good advice
on the topic.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#7662 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADFATBT6G6QX525WZJ4KJDSBSMD3ANCNFSM4QFCZVNA>
.
|
Currently the
So I think it is reasonable to write local time + UTC offset as @graingert mentioned. |
@jinxudb would you like to give that a try? Should be a simple patch (change that line + test + a changelog). |
junit-team/junit5#373 looks like it's sort of implementation defined, so would be a good idea to test it on a real Jenkins box |
Thanks @graingert. 👍 From the docs at https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html, that format does not include the time zone, but of course it doesn't mean that a Jenkins box cannot read time zone information if it is present. Can anybody with access to a Jenkins box test this? |
@nicoddemus we should also make sure that we store the timestamp of when the test started, not finished. This way a consumer can determine the end time of a test from |
@nicoddemus I think we should only land this if Junit5 also lands the same change |
getTimestamp is an undocumented String getter: https://javadoc.jenkins.io/plugin/junit/hudson/tasks/junit/SuiteResult.html#getTimestamp-- |
I'm not sure how it is currently, but I would not change the current behavior.
Hmmm sorry, what's junit5?
Bummer. I guess someone can try that in a Jenkins instance and see if it works. @jinxudb could you check if adding the time zone information to that timestamp works on Jenkins? You can do that by post-processing the generated XML file to include the time zone information using a custom script, just to check how Jenkins behaves. If it works we will feel safer to include that change into pytest. |
It appears that "junit" xml is implementation defined by whatever junit5 emits and Jenkins consumes |
do we need to make the same change for xunit2? |
also Junit5 outputs timezone in the //testsuite/properties/property
|
<xs:attribute name="timestamp" type="ISO8601_DATETIME_PATTERN" use="required">
<xs:annotation>
<xs:documentation xml:lang="en">when the test was executed. Timezone may not be specified.</xs:documentation>
</xs:annotation>
</xs:attribute> You could read this as "Timezone may not be specified." or "Timezone may not be specified." |
Any update on this issue? I think that having some timezone information in the timestamp makes sense. It looks like the JUnit plugin for Jenkins does support datetimes with timezone information as shown in this sample file that's a part of their tests. This test here shows that the suites included in the sample junit xml file should be parsed correctly. So I think as long as the timestamp generated by the junitxml plugin matches one of the valid ones shown in the sample file then it should be compatible with Jenkins. |
Last year, pytest add attribute to the JUnit test report. In the test report I can see the timestamp like
timestamp="2020-08-17T10:14:39.548365"
It looks like pytest just takes the system time from OS, and save it to test report.
Unfortunately, this timestamp doesn't have any timezone infomation, Our CI system will treat this timestamp as a UTC time, even the timestamp is actually from another time zone.
pytest 5.2.1, I have seen the issue in both Linux and Windows
Is it possible to add timezone information to the timestamp attribute, or always use UTC time in timestamp?
The text was updated successfully, but these errors were encountered: