-
-
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
Allow recording custom xml attributes #3130
Comments
I believe #2770 address this. |
@nicoddemus I might be missing something here, but I'm not sure that #2770 addresses this. #2770 makes the addition of custom properties easier (and seems to be agnostic to reporting format), but will likely still break output parsing for ci tools. I'm working on a PR for this which might help clear up my intentions here. Currently, an xunit file from a test that uses <?xml version="1.0"?>
<testsuite errors="0" failures="0" name="pytest" skips="0" tests="1" time="0.014">
<testcase classname="test_fixtures.TestCustomMetadataInjection" file="test_fixtures.py" line="99" name="example" time="0.00146698951721">
<properties>
<property name="assertions" value="REQ-1234, REQ-5678, REQ-9101"/>
</properties>
<system-out>
hello world
</system-out>
</testcase>
</testsuite> What I'd like to do is this: <?xml version="1.0"?>
<testsuite errors="0" failures="0" name="pytest" skips="0" tests="1" time="0.014">
<testcase classname="test_fixtures.TestCustomMetadataInjection" file="test_fixtures.py" line="99" name="example" time="0.00146698951721" assertions="REQ-1234, REQ-5678, REQ-9101">
<system-out>
hello world
</system-out>
</testcase>
</testsuite> |
update incorrect expected attribute value in test_record_attribute
update incorrect expected attribute value in test_record_attribute attr names must be strings
update incorrect expected attribute value in test_record_attribute attr names must be strings
Hi @raphaelcastaneda indeed they are not the same thing, thanks for the detailed explanation. I added some comments to your PR, please take a look when you get the time! 👍 |
Thanks for looking this over @nicoddemus. I've updated the usage documentation. Please let me know if you'd like any additional changes. |
Thanks @raphaelcastaneda. The PR LGTM and I've approved it, let's wait a few days to give the other maintainers a chance to review as well. |
update incorrect expected attribute value in test_record_attribute attr names must be strings Update CHANGELOG formatting update usage documentation Fix versionadded for record_xml_attribute Indent the xml schema properly inside the warning box in the docs
update incorrect expected attribute value in test_record_attribute attr names must be strings Update CHANGELOG formatting update usage documentation Fix versionadded for record_xml_attribute Indent the xml schema properly inside the warning box in the docs
…-attribute implement #3130 - add record_xml_attribute fixture
- add fromstring support, ref:https://docs.python.org/3/library/xml.etree.elementtree.html#parsing-xml - add MSTest trx support(parse_trx, fromstring_trx), ref: https://gist.github.com/congzhangzh/92ca9692430a95e3dce98f4ae2c0004e, https://gist.github.com/congzhangzh/30ecfd89fa9f0d4139c585869d2df81f, https://github.com/x97mdr/pickles/blob/master/src/Pickles/Pickles.Test/results-example-mstest.trx - add pytest record_xml_property support, ref: pytest-dev/pytest#3130
@raphaelcastaneda thank you for your contribution! Do you plan to make it compatible with pytest-xdist? |
I do not plan on implementing this. Though looking through the history of the project, I imagine a similar conversion is needed as was done for |
The experimental fixture
record_xml_property
inserts an additional<properties>
element into the<testcase>
element.This violates typical junit xml validation, causing many parsers (e.g. Jenkins xunit plugin) to fail when processing pytest xml output that contains these extra properties.
While additional properties are very likely to break junit parsers, attributes may not.
For example, the junit spec does allow for an additional optional string attribute called
assertions
:As a test author, I would like to be able to insert my own attributes on a testcase element.
Proposal:
record_xml_attribute
that allows a test author to add an attribute to the existing<testcase>
element in the xml report.name
andvalue
The text was updated successfully, but these errors were encountered: