-
-
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
junitxml: add properties node in testsuite level #1454
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -193,6 +193,53 @@ This will add an extra property ``example_key="1"`` to the generated | |
Also please note that using this feature will break any schema verification. | ||
This might be a problem when used with some CI servers. | ||
|
||
LogXML: add_global_property | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
.. versionadded:: 2.10 | ||
|
||
If you want to add a properties node in the testsuite level, which may contains properties that are relevant | ||
to all testcases you can use ``LogXML.add_global_properties`` | ||
|
||
.. code-block:: python | ||
|
||
import pytest | ||
|
||
@pytest.fixture(scope="session") | ||
def log_global_env_facts(f): | ||
|
||
if pytest.config.pluginmanager.hasplugin('junitxml'): | ||
my_junit = getattr(pytest.config, '_xml', None) | ||
|
||
my_junit.add_global_property('ARCH', 'PPC') | ||
my_junit.add_global_property('STORAGE_TYPE', 'CEPH') | ||
|
||
@pytest.mark.usefixtures(log_global_env_facts) | ||
def start_and_prepare_env(): | ||
pass | ||
|
||
class TestMe: | ||
def test_foo(self): | ||
assert True | ||
|
||
This will add a property node below the testsuite node to the generated xml: | ||
|
||
.. code-block:: xml | ||
|
||
<testsuite errors="0" failures="0" name="pytest" skips="0" tests="1" time="0.006"> | ||
<properties> | ||
<property name="ARCH" value="PPC"/> | ||
<property name="STORAGE_TYPE" value="CEPH"/> | ||
</properties> | ||
<testcase classname="test_me.TestMe" file="test_me.py" line="16" name="test_foo" time="0.000243663787842"/> | ||
</testsuite> | ||
|
||
.. warning:: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please make a copy this warning to just before the start of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
This is an experimental feature, and its interface might be replaced | ||
by something more powerful and general in future versions. The | ||
functionality per-se will be kept. | ||
|
||
Creating resultlog format files | ||
---------------------------------------------------- | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a blank line before this one otherwise this won't show up correctly in the generated HTML
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done