GithubHelp home page GithubHelp logo

isabella232 / pytest-nunit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pytest-dev/pytest-nunit

0.0 0.0 0.0 1.2 MB

An Nunit output plugin for Pytest

License: MIT License

Python 100.00%

pytest-nunit's Introduction

pytest-nunit

PyPI version

Python versions

PyPI download month

A pytest plugin for generating NUnit3 test result XML output

Requires: - Pytest 4.6+ - Python 3.6+

Command-line options

--nunit-xml

A string value to set the file name of the generated XML file.

Argument takes a path to the output file, either relative, or absolute.

--nunit-prefix

A string value to prefix all test case names the string provided.

Defaults to an empty string.

INI Options

nunit_show_username

Boolean value to include the system username in the test run properties.

Defaults to false

nunit_show_user_domain

Boolean value to include the system user domain in the test run properties.

Defaults to false

nunit_suite_name

(Deprecated, value ignored)

String value to set the test suite name.

Defaults to 'pytest'

nunit_attach_on

Enumeration to control whether the attachments property is set on all test cases when the add_nunit_attachment is used.

Can be one of:

  • any - Include test attachments for all outcomes (Default)
  • pass - Include test attachments for only passed test cases
  • fail - Include test attachments for only failed test cases

Fixtures

The following fixtures are made available by this plugin.

record_nunit_property

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_nunit_attachment

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

Usage with Azure Pipelines

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

Skipped tests will have the reason attribute (if provided) included in the results.

image

Attachments

Using the add_nunit_attachment fixture will render any attachments in the "attachments" tab inside the Tests console:

image

Failures and xfails

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.

image

Compatibility with other plugins

x-dist

When running with -f, make sure to add in your pytest config file (setup.cfg etc) looponfailroots = testdir to exclude xml report files from being watched for changes.

Check looponfails

History

0.6.0 (4th August 2020)

  • fix unicode escapes in cdata (#39)
  • fix start/stop time calculation (#42)
  • dropping support for python3.4 (#45)
  • dropping support for old xdist versions (#44)

0.5.3 (15th April 2020)

  • Bugfix - Fix time taken for tests under certain scenarios causing crash on pytest_sessionfinish

0.5.2 (30th August 2019)

  • Bugfix - Escape tabbed unicode characters from stdout feed from being in CDATA output

0.5.1 (30th August 2019)

  • Bugfix - Fixed cause of crash for tests that could be discovered but never executed

0.5.0 (30th August 2019)

  • Docstrings of nodes (functions) are set as the label for TestCase elements (contribution by @mikeattara)
  • Pytest -k keyword filters are added to the test run filter element under name.
  • Pytest -m marker filters are added to the test run filter element under namespace.
  • Any path filters are added to the test run filter element under test.
  • Each Python module containing tests is now a separate test-suite element, instead of having one large suite
  • Docstrings of modules are set as the label for TestSuite elements

0.4.0 (28th August 2019)

  • Added user domain (contribution by @williano)
  • Added tests and help for xdist execution (contribution by @mei-li)
  • Dynamically use the keyword list when generating schema to avoid reserved word collision (contribution by @gerhardtdatsomor)
  • Add method names, classnames and module names to output (contribution by @adekanyetomie)
  • Added locale and uiculture properties to runtime output (contribution by @terrameijar)
  • Added nunit_attach_on INI option to control when attachments are included in test cases.

0.3.0 (15th July 2019)

  • Added --nunit-prefix option.

0.2.1 (15th July 2019)

  • First stable release

pytest-nunit's People

Contributors

tonybaloney avatar asottile avatar mei-li avatar attaradev avatar zooba avatar caselit avatar broglep-work avatar terrameijar avatar williano avatar adekanyetomie avatar datgerhardt avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.