码迷,mamicode.com
首页 > 其他好文 > 详细

pytest 生成测试报告

时间:2020-07-23 16:50:29      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:data-   for   his   def   cte   collect   item   root   plugins   

pip安装

pip install pytest-html

编写脚本

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

    def test_two(self):
        x = "hello"
        assert h in 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.1, metadata-1.8.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测试报告文件打开如下

技术图片

 

pytest 生成测试报告

标签:data-   for   his   def   cte   collect   item   root   plugins   

原文地址:https://www.cnblogs.com/hy546880109/p/13366222.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!