Python单元测试框架pytest常用测试报告类型

本文介绍了Python的pytest框架如何生成不同类型的测试报告,包括allure报告、resultlog文件、JunitXML文件、测试用例URL和HTML测试报告,详细讲解了相应的生成命令和用途。
摘要由CSDN通过智能技术生成

先前博客有介绍pytest测试框架的安装及使用,现在来聊聊pytest可以生成哪些测试报告

1.allure测试报告

关于allure报告参见先前的一篇博文:https://www.cnblogs.com/feng0815/p/13792188.html ,这里不再赘述

2.生成resultlog文件

#!/usr/bin/python
# -*- coding: UTF-8 -*-
"""
@author:chenshifeng
@file:test_report.py
@time:2021/01/27
"""
class TestReport:

    def test_one(self):
        x = "shifeng"
        assert "feng" in x

    def test_two(self):
        x = "hello"
        assert x == "hi"

执行命令:

 pytest test_report.py  --resultlog=./resultlog.txt

指定当前路径下生成resultlog.txt文件,打开文件,内容如下:

. reportdemo/test_report.py::TestReport::test_one
F reportdemo/test_report.py::TestReport::test_two
 self = <test_report.TestReport object at 0x7fd9c0a3eac0>
 
     def test_two(self):
         x = "hello"
 >       assert x == "hi"
 E       AssertionError: assert 'hello' == 'hi'
 E         - hi
 E         + hell
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值