Giter VIP home page Giter VIP logo

pytest-nunit's Introduction

pytest-nunit

Build status PyPI version Python versions PyPI download month

A pytest plugin for generating NUnit3 test result XML output

This plugin is an early beta release!

Configuration

--nunit-xml

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.

--nunit-prefix

Use --nunit-prefix=example- to prefix all test case names with "example-"

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.

https://github.com/pytest-dev/pytest-nunit/raw/master/docs/source/_static/screen_skips.png

Attachments

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

https://github.com/pytest-dev/pytest-nunit/raw/master/docs/source/_static/screen_attachments.png

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.

https://github.com/pytest-dev/pytest-nunit/raw/master/docs/source/_static/screen_fails.png

History

0.3.0 (15th July)

  • Added --nunit-prefix option.

0.2.1 (15th July)

  • First stable release

pytest-nunit's People

Contributors

tonybaloney avatar asottile avatar terrameijar avatar

Watchers

James Cloos 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.