【pytest】 allure 生成报告

1. 下载地址

官方文档;

Allure Framework

参考文档: 最全的Pytest+Allure使用教程,建议收藏 - 知乎

https://github.com/allure-framework

1.2安装Python依赖

复制代码
windows:pip install allure-pytest

2. 脚本

用例

复制代码
import pytest
class Test_Smoke:
    def test_01(self):
        assert 1+1==2
    @pytest.mark.smoke
    def test_02(self):
        assert 1+2==1

    @pytest.mark.smoke
    def test_03(self):
        assert 1 + 2 == 3

import pytest

if __name__=='__main__':
    print("hhhhhhh")
    

    pytest.main(['-s', '-v', '-m smoke', './somke_test','--alluredir=./report/allure', '--html=./report/result.html'])

清空历史数据'--clean-alluredir'

复制代码
#    清空历史数据'--clean-alluredir'
pytest.main(['-s', '-v', '-m smoke', './somke_test','--clean-alluredir', '--alluredir=./report/allure', '--html=./report/result.html'])

管理员打开 pycharm 运行

3.显示报告

3.1添加环境变量

3.2查看报告使用:allure serve 目录

3.3切换为中文

相关推荐
bjwuzh1 天前
使用pytest实现参数化后,控制台输出的日志是乱码
pytest
2025年一定要上岸2 天前
pytest框架 - 第二集 allure报告
pytest
头疼的程序员3 天前
allure生成测试报告(搭配Pytest、allure-pytest)
测试工具·pytest
文人sec4 天前
接口自动化测试设计思路--设计实战
python·https·单元测试·自动化·pytest
测试开发Kevin6 天前
从投入产出、效率、上手难易度等角度综合对比 pytest 和 unittest 框架
python·pytest
测试开发Kevin8 天前
以pytest_addoption 为例,讲解pytest框架中钩子函数的应用
python·pytest
川石教育13 天前
Pytest中的fixture装饰器详解
python自动化测试·pytest·pytest自动化测试框架·pytest测试框架·pytest单元测试框架
春风又。14 天前
接口自动化——参数化
python·测试工具·自动化·pytest
XTY0016 天前
mac电脑pytest生成测试报告
pytest
程序员的世界你不懂16 天前
pytest-前后置及fixture运用
pytest