Skip to main content

Behave library to integrate with Testrail API

Project description

# Behave to TestRail Reporter

Build: [![CircleCI](https://circleci.com/bb/virtualstock/behave-testrail-reporter/tree/master.svg?style=svg&circle-token=360d1d5cbd8ae09d97d5fbff1d4c345d1fd94428)](https://circleci.com/bb/virtualstock/behave-testrail-reporter/tree/master)

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()`

```python
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:


```yaml
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:

```gherkin
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](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.0.1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

behave_testrail_reporter-0.0.1-py2-none-any.whl (6.9 kB view details)

Uploaded Python 2

File details

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

File metadata

File hashes

Hashes for behave-testrail-reporter-0.0.1.tar.gz
Algorithm Hash digest
SHA256 3292d7f75d4b2bfd4900e48d45a54511045098994f69f4d6512f48335593cec0
MD5 0b8f7e5c042eb9c8c4a83867c5f0e5c9
BLAKE2b-256 dc53672c5d89c65a2fbe12767e7422eef94a9ab080081662af0546df207c6843

See more details on using hashes here.

File details

Details for the file behave_testrail_reporter-0.0.1-py2-none-any.whl.

File metadata

File hashes

Hashes for behave_testrail_reporter-0.0.1-py2-none-any.whl
Algorithm Hash digest
SHA256 ab510e9ecdee07a4424bee3ddd703401f761eeb19011899148973b35143bc409
MD5 a4e078744968868a47aa2d4044526771
BLAKE2b-256 10b8a7be365717c59b5fabf471edac237edf644ca17bf31a9d51b66820dec10c

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