-
Notifications
You must be signed in to change notification settings - Fork 6
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
Cannot read properties of undefined (reading '0') #16
Comments
Just looked up some guideline about xUnit and found out that my xml file looks more like jUnit. But setting the task up to interprete a jUnit file gives the same error. edit: The more I look at this here https://github.com/testmoapp/junitxml?tab=readme-ov-file#complete-junit-xml-example the more I think the problem is a not correct implementation of the xml file generation... |
The 3rd party library I'm using to read through the test results doesn't like the file that you're providing. The xml you supplied is definitely not xUnit. Take a look at some of the sample test data in the source code: PublishTestPlanResultsV1/test/data. I took your sample xml and wrote a quick unit test to see what is breaking when the file is parsed. It looks like the JUnit parser is expecting a top-level node I think the challenge is there is no formal JUnit schema defined in the JUnit project. I've identified two reference examples:
My research suggests that the java implementation has a legacy reporter that generates an xml file per test suite, and an extra step is required to aggregate the files into a single xml file. The java implementation also has an Open Test Reporter format that generates a single file with I can open a defect in the testparser project to add support for mixed formats ( In the meantime, you might need to add a small script that can massage your xml. This would be temporary until the testparser is resolved. Something like this powershell task: # create a top-level node
$root = [xml]"<testsuites count='0' />"
# read the existing xml file into memory
$existing = [xml](Get-Content -Path testcafe/result.xml)
# import the node into the same document namespace
$testSuite = $root.ImportNode( $existing.testsuite, $true )
# add the imported element
$root.testSuites.AppendChild( $testSuite )
# save the changes
$root.Save( 'testcafe/result.xml' ) |
thanks for your research and effort! your first reference example states the following at https://github.com/testmoapp/junitxml?tab=readme-ov-file#complete-junit-xml-example :
azure dev ops is for example such a tool that excepts it without this testsuites root-element. i will see what i can do but as this is not your fault i will close this ticket. thanks a lot - i will go on trying to get your extension running for me ;-) |
Does TestCafe emit the testsuites root element if there's more than one suite? |
it emits it in any case... https://github.com/alexschwantes/testcafe-reporter-junit/blob/master/src/index.js -> there is no "testsuites"-tag. i will look if i can write my own reporter - does not look that complicated... |
I wouldn't worry about creating a custom reporter. As per the thread above, I've submitted a PR to the test-parser library that this project uses. The PR has been merged, but I need the owner to publish the changes to the npm repository. The work item for that is here: test-results-reporter/parser#46 As soon as the owner of that project creates a release with the changes, I can update publish a new version of the extension with the updated dependency.. |
@quotschmacher - the test-parser dependency has been updated to 0.1.7 which includes support for Please advise if you have any further issues. Closing this issue. |
@quotschmacher - following up. Were you able to publish your results ok? |
Description
The XML xUnit file cannot be processed.
Environment Details
The xUnit file
Pipeline Output
provide output from the build with diagnostics enabled (system.debug variable set to 'true'). Mask secrets or sensitive information with xxx:
The text was updated successfully, but these errors were encountered: