Behave库与Testrail API集成
项目描述
Behave到TestRail报告器
此集成用于在Behave测试执行时自动将测试结果添加到TestRail。
生成报告的示例
3 testrail test cases passed, 0 failed, 19 skipped, 2 untested
Took 0m6.349s
安装
可以使用pipenv安装
$ pipenv install behave-testrail-reporter
或使用pip
$ pip install behave-testrail-reporter
设置
将 TestrailReporter
添加到您的 /features/environment.py
中的行为报告器,通过在 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)
在您项目的根目录下创建一个 testrail.yml
配置文件
示例结构
base_url: https://your-domain.testrail.io
projects:
- name: 'Advanced tests on branch {branch}'
id: 123
suite_id: 456
# note: this will allow any branch to push test case results to Testrail.
allowed_branch_pattern: '.*'
- name: 'Smoke tests on branch {branch}'
id: 1234
suite_id: 789
# note: this will allow any branch to push test case results to Testrail.
allowed_branch_pattern: '.*'
只允许 master 分支和 release1.111.1 推送测试结果到 Testrail
base_url: https://your-domain.testrail.io
projects:
- name: 'Full E2E tests on branch {branch}'
id: 123
suite_id: 456
allowed_branch_pattern: '^(master|release\/\d+([\.\d]+)?)$'
yml 键 | 描述 |
---|---|
name | 项目名称 |
id | Testrail 项目 ID |
suite_id | Testrail 套件 ID |
allowed_branch_pattern | 限制测试运行执行时的正则表达式 |
name - 您可以使用一些项目变量来创建动态测试运行名称
变量 | 示例 | 结果 |
---|---|---|
{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 |
需要的环境变量
变量名称 | 描述 |
---|---|
TESTRAIL_KEY | TestRail 用户密码 |
TESTRAIL_USER | TestRail 用户电子邮件地址 |
如何使用
为了在 TestRail 上标记测试用例为成功或失败,我们必须在每个场景中添加带有 TestRail 测试用例 ID 的标签。
测试用例标签结构
prefix
+ test case id
@testrail-
+ C1104
请看下面的示例
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
注意:某些场景可以涵盖多个 TestRail 用例,为此您只需要添加多个标签。
如何贡献
安装开发依赖项
pipenv install --dev
如何运行测试
激活您的虚拟环境,然后运行 tox。
tox
如何分发
如果您需要发布此包的新版本,可以使用以下命令
python setup.py sdist bdist_wheel
twine upload dist/*
许可协议
许可协议为 MIT 协议
。查看 许可协议。
项目详情
下载文件
下载适用于您的平台文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。
源分布
behave-testrail-reporter-0.5.1.tar.gz (13.0 kB 查看散列)
构建分布
关闭
散列 为 behave_testrail_reporter-0.5.1-py2.py3-none-any.whl
算法 | 散列摘要 | |
---|---|---|
SHA256 | f0fad50c6c3a27ae6e8919736b474c8d520dd6bc3c710d3764b93570b4b43a54 |
|
MD5 | 13cc001391363a351bf4a0d998a5e9a6 |
|
BLAKE2b-256 | 29ac781b519463577eddbedec43c738193dde5fae4838dcfa2981a61980b562d |