pytest测试框架
pytest测试框架
Tim8709
这个作者很懒,什么都没留下…
展开
-
pytest自定义插件
参考资料https://docs.pytest.org/en/latest/plugins.html(Installing and Using plugins)https://docs.pytest.org/en/latest/writing_plugins.html#writing-plugins(Writing plugins)https://docs.pytest.org/en/latest/_modules/_pytest/hookspec.html(Source code for _pyte原创 2020-11-10 14:35:39 · 764 阅读 · 0 评论 -
pytest+allure生成测试报告
官方文档http://allure.qatools.ru/https://docs.qameta.io/allure/#Allure框架介绍灵活的、轻量级的测试报告工具支持多平台:windows、mac、linux支持多语言:java、python、PHP、ruby提供详尽的测试报告、测试步骤、日志可与jenkins集成安装windows:https://github.com/allure-framework/allure2/releases下载allure2.7.zip包解原创 2020-10-11 21:11:41 · 1300 阅读 · 3 评论 -
pytest配置文件
简介pytest.ini是pytest的配置文件,一般放在根目录,且不能有中文。通过配置文件,可以改变pytest的运行方式。pytest --help[pytest] ini-options in the first pytest.ini|tox.ini|setup.cfg file found: markers (linelist): markers for test functions empty_parameter_set_mark (string):原创 2020-10-10 15:22:51 · 271 阅读 · 0 评论 -
pytest常用插件
pytest-rerunfailures失败重试插件pip install pytest-rerunfailures注:1 不要与setup_class一起使用2 一个测试用例上面不要有多个装饰器3 Python要3.5以上版本,pytest要5.0以上版本import pytestdef test_div(): assert 1 == 2==================# 命令行执行以下命令(失败重复执行5次,每次延迟1秒)pytest --reruns 5 --rer原创 2020-10-09 17:57:17 · 455 阅读 · 0 评论 -
pytest.fixture
fixture的作用fixture在测试函数前后运行,代码可以定制,满足多变的测试需求功能包括:定义传入测试中的数据集、配置测试前系统的初始状态、为批量测试提供数据源等fixture是pytest把在测试前后做预备和清理工作的代码,分离出核心逻辑的一种机制使用场景用例1需要登录,用例2不需要登录,用例3需要登录,这种场景无法通过setup、teardown实现;要想实现此场景,就用到fixture了使用方法调用fixture函数的两种方式:1 把函数当做参数传入 2 用usefixtures原创 2020-10-07 08:43:01 · 250 阅读 · 0 评论 -
自动化测试用例的设计原则
自动化测试的目的为了将测试人员从大量重复的测试工作中解脱出来,使其专注于更有价值的测试,如探索式测试。自动化测试不是为了发现问题,而是为了验证功能,故自动化测试一般用于冒烟测试和回归测试。自动化测试用例的设计原则自动化测试用例范围往往是核心业务、流程或者重复执行率较高的功能自动化测试用例尽量只做正向逻辑的验证,不要考虑太多逆向逻辑的验证每条测试用例只覆盖1条基本功能(只有1个断言)测试用例之间尽量不要有关联如果修改了数据,需要还原数据...原创 2020-10-05 07:37:59 · 450 阅读 · 1 评论 -
pytest.mark
pytest.mark.标记我们把某些用例做特殊标记,执行用例时只执行这些标记过的用例,如把用例标记为冒烟用例@pytest.mark.smokedef test_func(): pass==================运行:pytest -m smokepytest.mark.skip调试时不想运行某些用例,或在某些版本/平台中跳过,或外部资源不可用(如数据库连接失败),就用到skip或skipifskip@pytest.mark.skipdef test_func():原创 2020-10-03 08:48:58 · 72 阅读 · 0 评论 -
pytest参数化与数据驱动
使用在方法上写装饰器@pytest.mark.parametrize(argnames,argvalues)argnames:要参数化的变量名,可以是string、list、tupleargvalues:参数化的值,可以是list、list[tuple]string‘’'python原创 2020-09-30 08:59:53 · 684 阅读 · 0 评论 -
pytest用例识别与运行
官方文档:https://docs.pytest.org/en/latest/contents.html#toc安装pip install pytestpip install -U pytest #更新运行pytest #执行当前目录下以test开头的文件,原创 2020-09-25 17:06:37 · 1720 阅读 · 0 评论 -
pytest安装
官方文档:https://docs.pytest.org/en/latest/contents.html#toc安装pip install pytestpip install -U pytest #更新用例识别以 test_ 开头,或以 _test 结尾的 py 文件;以 Test 开头的类(类中不能有 __init__ 方法);类中以 test_ 开头的方法;以 test_ 开头的方法...原创 2020-09-25 13:21:03 · 139 阅读 · 0 评论