allure-pytest环境准备
windows环境相关:
python 3.7版本
pytest 5.4.3版本
allure-pytest 2.8.17 最新版
使用pip install allure-pytest安装
allure命令行工具
allure是一个命令行工具,需要去github上下载最新版https://github.com/allure-framework/allure2/releases
下载完成之后,解压到本地电脑
把bin目录添加到环境变量Path下
用例demo
conftest.py内容
#conftest.py
import pytest
@pytest.fixture(scope="session")
def login():
print("用例先登录")
test_answers.py内容
#test_answers.py
# encoding:utf-8
import allure
import pytest
@allure.step("步骤1,点xx")
def steps_1():
print("11")
@allure.step("步骤2,点xx")
def steps_2():
print("22")
@allure.feature("编辑页面")
class TestEditPage():
'''编辑页面'''
@allure.story("这是一个xxx的用例")
def test_1(self,login):
'''用例描述:先登录再去执行xxx'''
steps_1()
steps_2()
print("xxx")
@allure.story("打开a页面")
def test_2(self,login):
'''用例描述:先登录再去执行yyy'''
print("yyy")
执行用例
cd 到test_answers.py所在的目录文件,命令行执行
pytest --alluredir ./report/allure_raw
执行完成后,在当前目录下,report目录会生成一个allure_raw的原始文件,这个只是测试报告的原始文件,不能打开成html报告
打开html的报告需要启动allure服务,启动命令如下
allure serve report/allure_raw
查看报告
默认使用IE打开,一直在转圈,复数链接,放到谷歌浏览器上,秒开
点EN 按钮可以查看中文报告
打开测试套,可以查看报告的详情,显示的还是很详细的
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。