Skip to content
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

Missing timestamp from test suite attributes in junit xml export #2410

Open
3 tasks done
GitHubEddie opened this issue Dec 5, 2023 · 1 comment
Open
3 tasks done
Labels

Comments

@GitHubEddie
Copy link

GitHubEddie commented Dec 5, 2023

Checklist

What is the issue?

The junit_schema_4.xsd contains an optional attribute called timestamp under the testsuite element.

The issue is during a junit result object conversion to XML the timestamp is not included. For example,

<testsuite name="&lt;ScriptBlock&gt;:1" tests="136" errors="0" failures="2" hostname="COMPUTER1" id="0" skipped="0" disabled="0" package="&lt;ScriptBlock&gt;:1" time="2.644" >

The testsuite timestamp attribute is useful for tools like Allure Reports.
Without the timestamp attribute the Allure dashboard looks like this ('UNKNOWN' in report title)
image

Expected Behavior

The expectation would be for the timestamp attribute to be present on the junit XML.

<testsuite name="&lt;ScriptBlock&gt;:1" tests="136" errors="0" failures="2" hostname="COMPUTER1" id="0" skipped="0" disabled="0" package="&lt;ScriptBlock&gt;:1" time="2.644" timestamp="2023-12-05T21:04:41.4970014Z">

With the timestamp attribute available the Allure Reports Overview returns a title with detail from the test
image

Steps To Reproduce

Export-JUnitReport -Result $PesterObject -Path "C:\JUnit_export.xml"

or

ConvertTo-JUnitReport -Result $PesterObject

Describe your environment

Pester version     : 5.5.0 C:\Program Files\WindowsPowerShell\Modules\Pester\5.5.0\Pester.psm1
PowerShell version : 5.1.22621.2506
OS version         : Microsoft Windows NT 10.0.22621.0

Possible Solution?

This should be resolved by adding something like this

$XmlWriter.WriteAttributeString('timestamp', (Get-UTCTimeString $Action.ExecutedAt))

to the Pester.psm1 function Write-JUnitTestSuiteAttributes

@fflaten fflaten added the Feature label Dec 8, 2023
@fflaten
Copy link
Collaborator

fflaten commented Dec 8, 2023

Thanks for the suggestion. Sounds like a good idea, as long as the implementation is compatible with Jenkins and other JUnit report readers. 👍

Based on what I've found it's expected to be local time without timezone information unlike NUnit3. See jest-community/jest-junit#43

Would you like to submit a PR for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants