-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
plugin: junitxmlrelated to the junitxml builtin pluginrelated to the junitxml builtin plugintype: enhancementnew feature or API change, should be merged into features branchnew feature or API change, should be merged into features branch
Description
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
:
<xs:element name="testcase">
<xs:complexType>
<xs:sequence>
<xs:element ref="skipped" minOccurs="0" maxOccurs="1"/>
<xs:element ref="error" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="failure" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="system-out" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="system-err" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="assertions" type="xs:string" use="optional"/>
<xs:attribute name="time" type="xs:string" use="optional"/>
<xs:attribute name="classname" type="xs:string" use="optional"/>
<xs:attribute name="status" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
As a test author, I would like to be able to insert my own attributes on a testcase element.
Proposal:
- Add an additional fixture called
record_xml_attribute
that allows a test author to add an attribute to the existing<testcase>
element in the xml report. - This new fixture should take in two parameters:
name
andvalue
- If a user specifies a name that overlaps with existing test case attributes, the user-specified values should overwrite the existing values.
- User-specified attribute names should be xml-escaped
Metadata
Metadata
Assignees
Labels
plugin: junitxmlrelated to the junitxml builtin pluginrelated to the junitxml builtin plugintype: enhancementnew feature or API change, should be merged into features branchnew feature or API change, should be merged into features branch