首页 > 其他分享 >pytest相关参数及allure生成report报告的相关参数

pytest相关参数及allure生成report报告的相关参数

时间:2022-08-30 11:37:32浏览次数:81  
标签:报告 -- pytest 用例 allure 参数

一、pytest的相关参数

-s 输出打印信息,关闭捕捉;(如果要生成报告,就需要去掉该参数)

-v 显示具体的详细信息;

-k 执行包含关键字的用例

-q 简化输出信息

-x 出现一条测试用例失败,则退出测试

-m 指定目录以及特定类或者方法执行

二、allure报告相关参数

1、生成报告相关

--alluredir=dir 指定报告的数据源文件目录路径

--clean-alluredir 每次情空

--allure-no-capture  不加载logging/stdout/stderr文件到报告( 这个我目前还没用到过)

# 生成allure报告的数据源文件,json格式;--clean是每次清空
    pytest.main(['--alluredir','./results','--clean-alluredir','./case/test_excel_V41.py'])
    # 生成allure报告,此处的--clean是保证在一个目录里重复生成allure报告(不加的话,只能生成一次,为了误操作覆盖);此处的-o 是输出报告,./report
    # 是输出报告的名称;
    # allure generat + 数据源文件目录 -o + 报告的目录  ;
    os.system('allure generate ./results -o ./report --clean')

 

2、allure的环境配置

环境配置这块回头需要研究下

allure的环境配置

1,添加文件environment.properties, 添加到allure的报告数据中result下面

文件格式如下:

systemVersion=win10

pythonVersion=3.7.9

allureVersion=2.9.43

 

baseUrl==10.0.0.119:8080

projectName=test

author=Matt, nick

[email protected]

注:环境配置不支持中文

2,添加环境配置2:添加文件environment.xml ,添加到allure的数据报告目录,result下

文件格式:

Browser

Chrome

Broswer.Version

63.0

Stand

Production

 

 

 

一、pytest的相关参数的其他参数

生成junit xml格式测试报告

pytest.main(['-s','--junit-xml=./report/log01.xml'])

执行标记的用例

 pytest.main(['-s','-m','slow'])

执行未标记的用例
pytest.main(['-s', '-m', 'not slow'])

用例失败控制,第n个用例失败后,结束测试执行

--maxfail=n

通过标记表达式执行

pytest -m slow  (该命令会执行被装饰器@pytest.mark.show装饰的所有测试用例)

多进程运行测试用例

pip install pytest-xdist  (安装pytest-xdist)

运行模式

pytest -n NUMCPUS

重新运行失败用例

pytest-rerunfailures  (是一个可以使pytest重新运行的测试插件,消除间歇性故障)

pip install pytest-rerunfailures (安装该插件)

参考博客:https://www.cnblogs.com/look888/p/15167248.html

 

标签:报告,--,pytest,用例,allure,参数
From: https://www.cnblogs.com/yxm-yxwz/p/16638703.html

相关文章