Skip to main content

Behave library to integrate with Testrail API

Project description

Behave to TestRail Reporter

CircleCI Codacy Badge Codacy Badge pullreminders

This integration is used to add test results to TestRail automatically when Behave tests are executed.

Example of the generated report:

3 testrail test cases passed, 0 failed, 19 skipped, 2 untested
Took 0m6.349s

Install

Can install it using pipenv

$ pipenv install behave-testrail-reporter

or using pip

$ pip install behave-testrail-reporter

Setup

Add TestrailReporter to behave reporters in your /features/environment.py by adding this code in before_all()

from behave_testrail_reporter import TestrailReporter

def before_all(context):
    # ... all your other awesome code in here
    current_branch = os.environ.get('CIRCLE_BRANCH') # Change this to get the current build branch of your CI system
    testrail_reporter = TestrailReporter(current_branch)
    context.config.reporters.append(testrail_reporter)

Create a testrail.yml config file in the root of your project

Example structure:

projects:
  -
    name: 'Test run {branch}'
    id: 123
    suite_id: 456
    # note: this will allow any branch to push test case results to Testrail.
    allowed_branch_pattern: '.*'

Allow only master branch and release1.111.1 to push test results to Testrail:

projects:
  -
    name: 'Test run {branch}'
    id: 123
    suite_id: 456
    allowed_branch_pattern: '^(master|release\/\d+([\.\d]+)?)$'
yaml key Description
name Project name
id Testrail project id
suite_id Testrail Suite id
allowed_branch_pattern Regular expression to restrict when a test run is executed

name - You can use some project variables to create dynamic test run names

Variable Example Result
{project_id} 'Test run {project_id}' Test run 123
{suite_id} 'Test run {suite_id}' Test run 456
{branch} 'Test run {branch}' Test run master

Environment variables required

Variable name Description
TESTRAIL_KEY TestRail user password
TESTRAIL_USER TestRail user email address

How to use

To get test cases marked as success or fail on TestRail we have to add tags with TestRail test case ID on each scenario.

Test case tag structure:

prefix + test case id

@testrail- + C1104

See example below:

Feature: Log in and out

    Background:
        Given I am logged out from Hub
        And I navigate to the home page

    @testrail-C1104
    @testrail-C45933
    Scenario: Admin can login
        When I enter the username admin
        And I enter the password admin
        And I click the Login button
        Then I see the admin's landing page

Note: some scenarios can cover multiple TestRail cases, for that you just need to add multiple tags.

How to contribute

Install dependencies for development

pipenv install --dev

How to run tests

Activate your virtual environment and then just run tox.

tox

How to distribute

If you need to publish a new version of this package you can use this command:

python setup.py sdist bdist_wheel
twine upload dist/*

License

Licensed under MIT license. View license.

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

behave-testrail-reporter-0.4.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

behave_testrail_reporter-0.4.0-py2.py3-none-any.whl (8.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file behave-testrail-reporter-0.4.0.tar.gz.

File metadata

  • Download URL: behave-testrail-reporter-0.4.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.20.0 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.16

File hashes

Hashes for behave-testrail-reporter-0.4.0.tar.gz
Algorithm Hash digest
SHA256 2ecce6148dbab6502f6d62acbf3364988c4048fecc70e81c63f4ffebc12ae610
MD5 96d44028147afd7be55997ebd5027188
BLAKE2b-256 08d546977fdf7f90778b8f2506c7810089fd5a65e05f3dc4fd888dcdf1a80e87

See more details on using hashes here.

File details

Details for the file behave_testrail_reporter-0.4.0-py2.py3-none-any.whl.

File metadata

  • Download URL: behave_testrail_reporter-0.4.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.20.0 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.16

File hashes

Hashes for behave_testrail_reporter-0.4.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 bcf6ac85c57d3bb805112ccce164ac07d2501e2869a9f8c335135a887de1c28b
MD5 fb2015892a90c548f4bd30499d698c63
BLAKE2b-256 b204421437f5f2970295475eb07ef6a7f33a64af7a35dccb663741ea3c28dfe7

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