Behave library to integrate with Testrail API
Project description
Behave to TestRail Reporter
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: 'Project Name'
id: 123
suite_id: 123
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 |
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 run tests
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file behave-testrail-reporter-0.1.0.tar.gz
.
File metadata
- Download URL: behave-testrail-reporter-0.1.0.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a68cb1de6daa4540d9d51272a77ee2ac43e30b2f43d440823969ee98bcd3d189 |
|
MD5 | 2a4b45b97949ede925824572c9ac0c84 |
|
BLAKE2b-256 | 3f0eb6a8b5a5b0fba9855336cd6e64b6386569b31975590a726e19caa23bfb44 |
File details
Details for the file behave_testrail_reporter-0.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: behave_testrail_reporter-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 698784d65247ff64098c395df78fb4644feebd82c4cb5b2239381bd5a6839687 |
|
MD5 | 45c010d4a472c8b7c4f19528543de791 |
|
BLAKE2b-256 | c76de300d53fefa8dd02e08def1a4dfebd20a34daa4221d7897bb98f91158648 |