@allure.feature('功能名称')
@allure.story('子功能名称')
with allure.step('步骤细节'):
@allure.attach('具体文本信息')
@allure.link('链接地址',name='链接名称')
@allure.testcase('测试用例管理平台链接')
#标记用例级别
@allure.severity(allure.severity_level.NORMAL)

执行测试用例
pytest [测试文件] --alluredir ./result/
pytest --alluredir report
生成测试报告
allure serve ./result/
生成html文件
allure generate 测试结果数据所在目录 -o 测试报告保存的目录 --clean
--clean:覆盖路径加--clean
allure generate ./result/ -o ./report/ --clean
报错及解决:
1.执行 pytest testcase/test_home.py --alluredir report
报这个错

解决办法:在conftest.py里把导入模块的绝对路径

2.安装allure后执行命令后报错module 'pytest' has no attribute 'allure'
解决
cmd执行如下命令:
pip uninstall pytest-allure-adaptor
pip install allure-pytest
网友评论