1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > python自动化框架pytest pdf_Python自动化测试框架-pytest python

python自动化框架pytest pdf_Python自动化测试框架-pytest python

时间:2019-03-19 09:45:48

相关推荐

python自动化框架pytest pdf_Python自动化测试框架-pytest python

安装

pip install -U pytest;

使用方式

代码示例:

import pytest

def test_a():

print("Test A")

assert 1 # 成功

def test_b():

print("Test B")

assert 0 # 失败

if __name__ == '__main__':

pytest.main(['-s', 'test_pytest.py'])

输出结果:

Pytest Exit Code含义清单

Exit code 0 所有用例执行完毕,全部通过

Exit code 1 所有用例执行完毕,存在Failed的测试用例

Exit code 2 用户中断了测试的执行

Exit code 3 测试执行过程发生了内部错误

Exit code 4 pytest 命令行使用错误

Exit code 5 未采集到可用测试用例文件

生成测试报告

1> 安装报告生成插件pytest-HTML

pip install pytest-html

2> 执行报告生成命令

pytest --html=./report.html

3> 目录下会生成assert目录和report.html结果报告文件

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。