Python测试框架之pytest(一)基础
一、Pyetst是什么?
- pytest 能够支持简单的单元测试和复杂的功能测试;
- pytest 可以结合 Requests 实现接口测试; 结合 Selenium、Appium 实现自动化功能测试;
- 使用 pytest 结合 Allure 集成到 Jenkins 中可以实现持续集成。
- pytest 支持 315 种以上的插件;
二、Pytest 环境安装
- 前提:本地已配置完成Python环境
- 第一种方式
pip install pytest
- 第二种方式 PyCharm 直接安装
三、Pytest 有哪些格式要求?
类型 | 规则 |
---|---|
文件 | test_开头 或者 _test 结尾 |
类 | Test 开头 |
方法/函数 | test_开头 |
注意:测试类中不可以添加__init__ 构造函数 |