随笔分类 -  pytest

摘要:1、pytest-parallel 安装: pip install pytest-parallel 常用参数配置: --workers=n:多进程运行需要加此参数, n是进程数。默认为1 --tests-per-worker=n:多线程需要添加此参数,n是线程数 如果两个参数都配置了,就是进程并行, 阅读全文
posted @ 2020-08-07 11:28 爱语默 阅读(2526) 评论(0) 推荐(1) 编辑
摘要:1、遇到找不到模块 使用pytest.in配置文件,指定python搜索路径 [pytest] python_paths = C://xxx//xxx//pycharmProjects//project 阅读全文
posted @ 2020-06-25 10:13 爱语默 阅读(1341) 评论(0) 推荐(0) 编辑
摘要:项目test下的目录结构 全局conftest.py import pytest # 当autouse=False时,测试用例需要传入参数,为True时,不需要传入参数 @pytest.fixture(scope="session",autouse=True) def start(): print( 阅读全文
posted @ 2020-05-14 18:08 爱语默 阅读(3785) 评论(0) 推荐(0) 编辑
摘要:环境准备: 1、安装allure工具 2、安装allure-pytest插件 pip install allure-pytest 3、配置环境变量:allure解压文件夹下bin目录添加到path环境变量中 4、测试环境是否成功:cmd allure 生成报告: 生成结果文件:pytest 测试套件 阅读全文
posted @ 2020-03-09 12:36 爱语默 阅读(213) 评论(0) 推荐(0) 编辑
摘要:用例标签: 执行测试用例:pytest 测试套件名 -m 标签名 import pytest ''' 用例标签: @pytest.mark.标签名 执行测试:pytest 测试套件名 -m 标签名 这样执行会有警告,提示标签未注册 注册标签: 方式一: 创建配置文件pytest.ini [pytes 阅读全文
posted @ 2020-03-09 12:30 爱语默 阅读(1182) 评论(0) 推荐(1) 编辑
摘要:用例目录结构-按照数据环境 在每层的初始化文件中定义初始化清除操作,其中有的初始化清除操作需要调用多次,需要设置scope=session 在执行测试用例时,需要依次主动去调用每层初始化清除操作函数 代码: 需要导入相应的模块,再进行使用 from tc_data_env.nodata import 阅读全文
posted @ 2020-03-03 16:10 爱语默 阅读(355) 评论(0) 推荐(0) 编辑
摘要:需要导入模块pytest 使用装饰器:pytest.fixture(scope='function',autouse=False) fixture()函数参数解释说明 fixture里面有个scope参数可以控制fixture的作用范围:session>module>class>function - 阅读全文
posted @ 2020-03-03 13:49 爱语默 阅读(665) 评论(0) 推荐(0) 编辑
摘要:初始化清除操作: 用例级别: def setup(): def teardown() 套件级别: def setup_module() def teardown_module() 类级别:(可以不加classmethod装饰器) def setup_class(self) def teardown_ 阅读全文
posted @ 2020-02-26 17:06 爱语默 阅读(769) 评论(0) 推荐(0) 编辑
摘要:pytest特点: 用例语言是纯python 不支持测试报告,但可以使用插件(pytest-html) 可以不导入pytest模块执行测试用例 兼容性强,可以执行unittest测试用例 pytest --help 查看帮助 pytest命名规则: 模块、函数、类与方法必须以test_开头 如果是嵌 阅读全文
posted @ 2020-02-26 16:59 爱语默 阅读(407) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示