A pytest plugin for generating NUnit3 test result XML output
This plugin is an early beta release!
Use --nunit-xml=output.xml
to create an NUnit3-compatible file called output.xml
Argument takes a path to the output file, either relative, or absolute.
Use --nunit-prefix=example-
to prefix all test case names with "example-"
The following fixtures are made available by this plugin.
Calling record_nunit_property(key: str, value: str) will result in Property tags being added to the test-case for the related node.
def test_basic(record_nunit_property):
record_nunit_property("test", "value")
assert 1 == 1
Add an attachment to a node test-case by calling the add_nunit_attachment(path: str, description: str) function with the filepath and a description.
def test_attachment(add_nunit_attachment):
pth = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'fixture.gif')
add_nunit_attachment(path, "peanut butter jelly time")
assert 1 == 1
Add the following steps to your build job to publish the results to Azure Pipelines:
- script: "pip install pytest-nunit"
- script: |
python -m pytest tests -v --nunit-xml=test-results.xml
continueOnError: true
- task: PublishTestResults@2
inputs:
testResultsFormat: NUnit
testResultsFiles: '**/test-results.xml'
Skipped tests will have the reason
attribute (if provided) included in the results.
Using the add_nunit_attachment
fixture will render any attachments in the "attachments" tab inside the Tests console:
Any failed tests, whether as xpass or xfail, will have the error output and comparison, as well as the failing line in the stack trace.
- Added
--nunit-prefix
option.
- First stable release