栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

pytest用allure生成测试报告

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

pytest用allure生成测试报告

参考:https://blog.csdn.net/galen2016/article/details/105687512【Pytest】使用Allure测试报告

1.安装allure,配置环境变量。把allure的bin目录地址放在系统变量(右键我的电脑--属性--高级系统设置--环境变量--系统变量--path--编辑--新建--“你的allure的bin目录地址”--确定)path里。

allure下载地址:https://github.com/allure-framework/allure2/releases


2.参考代码:test_allure_demo.py
import allure

@allure.step("步骤1:打开百度")
def step_1():
    print("111")


@allure.step("步骤2:输入关键字")
def step_2():
    print("222")


@allure.feature("搜索")
class TestEditPage():
    @allure.story("百度搜索")
    def test_1(self):
        '''这是测试百度搜索'''
        step_1()
        step_2()
        print("百度一下,你就知道")

    @allure.story("谷歌搜索")
    def test_2(self):
        '''这是测试谷歌搜索'''
        assert 1 == 2, "搜索失败"

3.PyCharm的Terminal窗口(pycharm里右键就能看到)运行:
 pytest test_allure_demo.py --alluredir ./report

4.再执行执行:allure serve report,就可以看到报告了。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/468580.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号