行为库与testrail api集成

behave-testrail-reporter的Python项目详细描述


按照TestRail Reporter的要求行事

CircleCICodacy BadgeCodacy Badgepullreminders

此集成用于在执行行为测试时自动将测试结果添加到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

设置

通过在before_all()中添加此代码,添加TestrailReporter以在/features/environment.py中表现记者行为

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

在项目根目录中创建一个testrail.yml配置文件

示例结构:

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

只允许master分支和release1.111.1将测试结果推送到testrail:

projects:-name:'Testrun{branch}'id:123suite_id:456allowed_branch_pattern:'^(master|release\/\d+([\.\d]+)?)$'
yaml keyDescription
nameProject name
idTestrail project id
suite_idTestrail Suite id
allowed_branch_patternRegular expression to restrict when a test run is executed

name-可以使用一些项目变量创建动态测试运行名

VariableExampleResult
{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

需要环境变量

Variable nameDescription
TESTRAIL_KEYTestRail user password
TESTRAIL_USERTestRail user email address

如何使用

要在testrail上获得标记为成功或失败的测试用例,我们必须添加带有testrail测试用例id的标记 在每个场景中。

测试用例标签结构:

prefix+test case id

@testrail-+C1104

请参见下面的示例:

Feature: Log in and outBackground:        Given I am logged out from HubAnd I navigate to the home page@testrail-C1104@testrail-C45933Scenario: Admin can login        When I enter the username adminAnd I enter the password adminAnd I click the Login buttonThen I see the admin's landing page

注意:有些场景可以覆盖多个testrail案例,因为您只需要添加多个标记。

如何贡献

安装开发依赖项

pipenv install --dev

如何运行测试

激活虚拟环境,然后运行tox。

tox

如何分配

如果需要发布此软件包的新版本,可以使用以下命令:

python setup.py sdist bdist_wheel
twine upload dist/*

许可证

根据MIT license授权。视图license

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
使用jaxrpc的Java eclipse WebService客户端   java编程方式在对象上写入名称   java Spring批处理:重试后跳过   java Android错误:错误:任务执行失败:应用程序:transformClassesWithDexForDebug'   带有清单文件nullPointerException的java Android元数据   spring Java Quartz调度作业停止运行   JavaMockito:如何在不调用实际方法的情况下,模拟带有参数和无效返回类型的静态方法?   java Tomcat连接池问题无法在关闭的连接上调用方法   java如何交换列表中的项目?   java如何停止线程并通过Toast在线程中正确显示文本?   java为什么连续写入OutputStream时偏移量0不会导致重复字节?   java我无法生成头文件   不兼容的返回类型错误java   修改值后键值对的java Jolt转换规范   java有自动更新Javadoc的工具吗?   java线程如何在ints自身实例类中共享变量   java继承一个非gwt模块   java Hibernate xml配置   使用netty4异步调用的java链接HTTP请求响应