摘要: 介绍 调用插件和conftest.py文件的初始化挂钩。 添加命令行选项 import pytest def pytest_addoption(parser:pytest.Parser): parser.addoption("--xxxx",default="xxxx",help="url") @p 阅读全文
posted @ 2022-11-16 17:47 zhq9 阅读(13) 评论(0) 推荐(0) 编辑
摘要: 介绍 config.cache是一个实例pytest.Cache:该config.cache对象允许其他插件和装置在测试运行中存储和检索值。要从 fixtures 请求访问它pytestconfig到您的 fixture 并使用pytestconfig.cache. 函数 mkdir返回给定的nam 阅读全文
posted @ 2022-11-15 10:39 zhq9 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 介绍 pytester是pytest框架的内置fixture,想使用pytester要在conftest.py或者是用例文件的最上面添加pytest_plugins = "pytester" 默认临时目录可以通过tmp_path fixture查看,也可以使用--basetemp=mydir定义临时 阅读全文
posted @ 2022-11-15 10:09 zhq9 阅读(37) 评论(0) 推荐(0) 编辑
摘要: tmp_path 介绍 tmp_path夹具返回一个测试调用的唯一临时文件目录,tmp_path是一个pathlib.Path对象。临时目录可以使用--basetemp=mydir指定 示例 @pytest.fixture() def get_weburl(tmp_path): print("zhq 阅读全文
posted @ 2022-11-14 14:59 zhq9 阅读(40) 评论(0) 推荐(0) 编辑
摘要: 介绍 在测试当中,fixture为测试用例提供服务,比如配置数据库、获取配置信息、环境准备清理等,对于一些复杂的测试用例编写带来了很大的帮助 fixture一般是定义到conftest.py文件当中,他的作用域是使用fixture的用例从里往外找,比如项目根下一个conftest文件,用例同级目录下 阅读全文
posted @ 2022-11-13 07:24 zhq9 阅读(51) 评论(0) 推荐(0) 编辑
摘要: 介绍 自定义标记首先要在pytest.ini 文件当中注册也可以通过fixture注册,不注册的话不影响使用但是执行的时候就会有警告 注册标记 # pytest.ini [pytest] markers = p0: 这是一个p0级别的标签 p1: 这是一个p1级别的标签 使用标签 import py 阅读全文
posted @ 2022-11-13 05:50 zhq9 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 介绍 xfail 是用来标记那些预期失败的用例,它是一个内部标记 将用例标记失败 不同的标记方法使用示例 @pytest.mark.xfail def test_01(): pass @pytest.mark.xfail(reason="功能还未提测") def test_01(): pass de 阅读全文
posted @ 2022-11-12 11:57 zhq9 阅读(14) 评论(0) 推荐(0) 编辑
摘要: 安装 在命令行中运行以下命令: pip install -U pytest 检查您是否安装了正确的版本: pytest --version 常用的执行命令 -q简短输出,在执行用例的时候加上-q会简洁输出 pytest -q xxx.py -k是根据表达式匹配用例并执行用例,表达式不区分大小写,可以 阅读全文
posted @ 2022-11-10 09:32 zhq9 阅读(49) 评论(0) 推荐(0) 编辑
摘要: jdk 安装 yum install java-11-openjdk* -y 验证是否安装成功 java -version 能查到版本号说明安装成功 jenkins下载安装 下载Jenkins 到指定目录下 cd /etc/yum.repos.d/ 下载依赖 wget http://pkg.jenk 阅读全文
posted @ 2022-11-04 11:07 zhq9 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 安装 mac 安装allure brew install alluer 安装插件 allure-pytest pip3 install allure-pytest 生成报告 第一种方式 pytest test_01.py --alluredir=./report --clean-alluredir 阅读全文
posted @ 2022-10-06 16:35 zhq9 阅读(17) 评论(0) 推荐(0) 编辑