Skip to main content

No project description provided

Project description

What is that?

This is a pytest plugin for reporting tests results to Xray Server . Xray comes in two flavours Xray Server and Xray Cloud which are significantly different. They have incompatible APIs.

This plugin works with Xray Server. If you want to work with Xray Cloud, use pytest-typhoon-xray

If you are interested in improving the plugin, read [API documentation for Xray Server] (https://docs.getxray.app/display/XRAY/REST+API)

Plugin installation

To install this library for use please enter the following command:

$ pip install pytest_xray_server

How to use this plugin

To start using the plugin, add it to the list pytest_plugins in conftest.py.

pytest_plugins = ["pytest_xray_server"]

And configure URL to your xray instance in pytest.ini:

[pytest]
xray_base_url = https://xray.example.com/rest/

In test cases use markers to associate a test function with a test key and test execution id:

import pytest

@pytest.mark.xray(test_key="PRDS-12345")
def test_my_function():
    assert True == True

Enable the plugin by passing the extra options to the command line when invoking the pytest runner:

$ pytest . --jira-xray --jira-xray-test-exec-key=PRDS-12121

where PRDS-12121 is Jira ticket ID of Test Execution ticket.

It is important that the environment variables XRAY_API_CLIENT_ID and XRAY_API_CLIENT_SECRET are set for pytest_xray_server to successfully post results to the Xray API.

export XRAY_API_CLIENT_ID=user.name
export XRAY_API_CLIENT_SECRET=password

Adding execution evidence.

Xray allows attachiching execution evidence in form of text (Results) and binary blobs (evidence). This plug-in lets you create both of the from tests using xray_result and xray_evidence fixtures

def test_my_function(xray_evidence, xray_result):
    xray_evidence(filename="screenshot.png", data=open('screenshot.png').read())
    xray_result(name='text results', log='chunk of text', status='PASS')

The fixtures work by appending evidence and resutls to node.user_properties, you could add evidence to it from pytest hooks. It is important to add a tuple of two elements with first element 'xray_result' or 'xray_evidence' and appropriate type of the second element.

from pytest_xray_server import models

item.user_properties.append(("xray_result", models.XrayResult(name='text results', log='chunk of text', outcome='passed')))

Maintenance notes

Please make sure that any new releases of the library use an incremented version number from the last. The following guidance is used to properly version bump this library {major}.{minor}.{patch}.

Major versions are increased for any new overall library features or general API breaking changes.

Minor versions are increased for any new features added or implementation changes to existing APIs.

Patch versions are increased for any bug fixes and non-breaking changes.

To automatically bump versions, best to install bump2version, then enter either of the following on the command line:

$ bump2version major

or

$ bump2version minor

or

$ bump2version patch

These commands automatically commits and tags a new version. Make sure to push tags to the server with

$ git push && git push --tags

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_xray_server-1.6.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

pytest_xray_server-1.6-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file pytest_xray_server-1.6.tar.gz.

File metadata

  • Download URL: pytest_xray_server-1.6.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for pytest_xray_server-1.6.tar.gz
Algorithm Hash digest
SHA256 6bef9ccaab7e6f2df6f3d939affe818989cf4423655c33a83d2a7d95ecc99dcd
MD5 ab31c684e7fde8175d46e8c683ff2308
BLAKE2b-256 c4b277adf13a6427440e2ba9f6a396651250db71ff53e9038e93edd339148184

See more details on using hashes here.

File details

Details for the file pytest_xray_server-1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_xray_server-1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 792af2fb98874140f9ce8f79aec92f8783247e5b1e76ba33cf11383a0cf3afcf
MD5 0e8db98bc6ad98db17acc4f5c7680e22
BLAKE2b-256 a013c7f054424ac5c2314d491aa9d70a5cb9c9179e880f78d204a8a7c79649b9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page