pytest生成测试报告

pip安装

pip install pytest-html

编写脚本

import pytest
class TestClass(object):
    def test_one(self):
        x = "this"
        assert 'h' in x

     test_two(self):
        x = helloin x

运行程序:

pytest --html=report.html

结果:

C:\Users\haiy\Desktop\code\iot_yjb_api
λ pytest --html=report.html
============================ test session starts ============================= platform win32 -- Python 3.7.1rc1,pytest-5.3.5,py-1.8.1,pluggy-0.13.1
rootdir: C:\Users\haiy\Desktop\code\iot_yjb_api
plugins: html-2.0.0
collected 2 items

test_api.py ..                                                          [100%]

- generated html file: file://C:\Users\haiy\Desktop\code\iot_yjb_api\report.html -
============================= 2 passed in 0.07s ============================

在当前目录生成一个report.html测试报告文件打开如下

 

相关文章

目录1、前言2、mark的使用(一)注册自定义标记(二)在测试...
用例执行状态用例执行完成后,每条用例都有自己的状态,常见...
什么是conftest.py可以理解成一个专门存放fixture的配置文件...
前言pytest默认执行用例是根据项目下的文件名称按ascii码去收...
前言:什么是元数据?元数据是关于数据的描述,存储着关于数...