pytest 测试报告

一:说明

   使用pytest 框架的时候,我们可以对测试结果,生成测试报告

   支持的第三方插件有很多,我们以  pytest-html  为例说明

 

二:pytest-html

pip install pytest-html   # 安装第三方库
# test_case1.py文件

def test_case01():
    assert 1==1

def test_case02():
    assert 1==2

def test_case03():
    assert 2==2

def test_case04():
    assert 2==3

运行结果:

# 运行命令
pytest --html=report.html --self-contained-html --tb=no

 

 (运行之后,会生成一个测试报告)

 

 (在浏览器中打开,查看测试报告)

 

 

三:allure-pytest

pip install allure-pytest    # 安装第三方插件
# test_case1.py文件

def test_case01():
    assert 1==1

def test_case02():
    assert 1==2

def test_case03():
    assert 2==2

def test_case04():
    assert 2==3

运行结果:

# 运行命令
pytest test_case1.py --alluredir ./report_alluredir --tb=no

 

 (运行之后,会生成测试报告)

 

 

 

 

posted @ 2021-04-01 17:34  Z_sun  阅读(375)  评论(0编辑  收藏  举报