随笔分类 - Pytest
摘要:一、安装 pip install pytest-metadata 二、查看pytest元数据 使用pytest 执行用例的时候加上 -v 参数(或--verbose),在控制台输出报告的头部就会输出元数据(metadata) >pytest --verbose test session starts
阅读全文
摘要:github: https://github.com/pytest-dev/pytest-xdist 分布式执行用例的设计原则 1.用例之间是独立的,用例之间没有依赖关系,用例可以完全独立运行【独立运行】 2.用例执行没有顺序,随机顺序都能正常执行【随机执行】 一、基本使用 1.安装pytest-x
阅读全文
摘要:特殊变量 collect_ignore 可以在conftest.py文件中声明以排除测试目录或模块。需要是list[str]。 collect_ignore = ["setup.py"] collect_ignore_glob 可以在conftest.py文件中声明,以使用Unix shell样式的
阅读全文
摘要:pytest.approx(num):断言两个数字(或两组数字)在某个容差范围内彼此相等。 由于浮点运算的复杂性,我们直觉期望相等的数字并不总是如此,此时可使用。 from pytest import approx >>> 0.1 + 0.2 == approx(0.3) True pytest.f
阅读全文
摘要:可由conftest.py文件来引用我们实现的所有Hook方法。 一、引导时的Hook方法 引导时的Hook方法要求尽早注册插件(内部和setuptools插件)。 1.pytest_load_initial_conftests(early_config,parser,args): 在命令行选项解析
阅读全文
摘要:Allure 是一款轻量级的开源自动化测试报告生成框架。它支持绝大部分测试框架,比如 TestNG、Junit 、pytest、unittest 等。 官网描述 https://docs.qameta.io/allure/#_pytest 1.Allure 下载安装 Allure 下载最新版本:ht
阅读全文
摘要:六、Pytest常用插件 插件列表网址:https://plugincompat.herokuapp.com 包含很多插件包,大家可依据工作的需求选择使用。 1、pytest-sugar pytest-sugar 改变了 pytest 的默认外观,添加了一个进度条,并立即显示失败的测试。它不需要配置
阅读全文
摘要:四、pytest运行方式 1.测试类主函数模式 pytest.main(["-s test_abc.py"]) 2.命令行模式 pytest 文件路径/测试文件名 3、Pytest Exit Code 含义清单 Exit code 0 所有用例执行完毕,全部通过 Exit code 1 所有用例执行
阅读全文
摘要:官方文档:https://docs.pytest.org/en/latest/contents.html python 鄙视链:pytest 鄙视 > unittest 鄙视 > robotframework 。 pytest 是 python 的第三方单元测试框架,比自带 unittest 更简洁
阅读全文

浙公网安备 33010602011771号