随笔分类 -  测试自动化学习 - pytest

摘要:pytest介绍 pytest 是一个功能齐全的 Python 测试工具,可以帮助编写更好的程序,不仅可以编写小测试,还可以扩展到复杂的功能测试 pytest文档 pytest官方说明文档 博客导航 <1>pytest:环境配置 <2>pytest:简单示例 <3>pytest:命名规范 <4>py 阅读全文
posted @ 2021-12-07 13:31 漓白 阅读(193) 评论(0) 推荐(0) 编辑
摘要:目录:测试自动化学习 - pytest 说明:本篇博客基于pytest 6.2.5 问题 使用中文命名用例,出现乱码 解决方案 conftest.py文件中,hook所有用例,修改编码方式 from typing import List def pytest_collection_modifyite 阅读全文
posted @ 2021-12-07 13:06 漓白 阅读(217) 评论(0) 推荐(0) 编辑
摘要:目录:测试自动化学习 - pytest 说明:本篇博客基于pytest 6.2.5 作用 pytest配置文件可以改变pytest的运行方式,它是一个固定的文件pytest.ini文件,读取配置信息,按指定的方式去运行 文件命名 pytest.ini 配置选项 打开终端窗口,敲 pytest --h 阅读全文
posted @ 2021-12-07 13:03 漓白 阅读(151) 评论(0) 推荐(0) 编辑
摘要:目录:测试自动化学习 - pytest 说明:本篇博客基于pytest 6.2.5 作用 实现pytest分布式执行 安装 pip install pytest-xdist 使用 终端命令:pytest -n 线程数量 注: 用例之间保持独立,不能有依赖关系 用例无顺序关系,可以随机执行 用例可以重 阅读全文
posted @ 2021-12-07 12:54 漓白 阅读(75) 评论(0) 推荐(0) 编辑
摘要:目录:测试自动化学习 - pytest 说明:本篇博客基于pytest 6.2.5 作用 控制用例执行顺序 安装 pip install pytest-ordering 使用 装饰器:@pytest.mark.run(order=执行顺序) 注: 优先执行order装饰的用例 由小到大依次执行ord 阅读全文
posted @ 2021-12-07 12:51 漓白 阅读(73) 评论(0) 推荐(0) 编辑
摘要:目录:测试自动化学习 - pytest 说明:本篇博客基于pytest 6.2.5 conftest文件 作用 全局文件,无需导入即可使用 #规则: 文件名不可更改,强制要求为conftest.py 文件需要放在根目录 文件内资源全局共享 执行顺序:本模块寻找资源 → conftest文件寻找资源 阅读全文
posted @ 2021-12-07 12:47 漓白 阅读(46) 评论(0) 推荐(0) 编辑
摘要:功能、步骤命名 功能名称:@allure.feature("功能名称") 子功能名称:@allure.story("子功能名称") 步骤细节:@allure.step("步骤细节") 按名称选择用例 根据功能名称选择:pytest 文件名 --allure-features "功能名称" 根据子功能 阅读全文
posted @ 2021-12-06 17:47 漓白 阅读(65) 评论(0) 推荐(0) 编辑
摘要:目录:测试自动化学习 - pytest 说明:本篇博客基于pytest 6.2.5 作用 实现前置步骤功能,方便用例调用 使用 装饰器:@pytest.fixture() import pytest @pytest.fixture() def fixture1(): print("\nfixture 阅读全文
posted @ 2021-12-06 17:47 漓白 阅读(43) 评论(0) 推荐(0) 编辑
摘要:目录:测试自动化学习 - pytest 说明:本篇博客基于pytest 6.2.5 先看看 allure 命令的帮助文档 打开终端,输入 allure -h allure 命令的语法格式 allure [options] [command] [command options] options 列表 阅读全文
posted @ 2021-12-06 17:45 漓白 阅读(171) 评论(0) 推荐(0) 编辑
摘要:目录:测试自动化学习 - pytest 说明:本篇博客基于pytest 6.2.5 java jdk 作用:allure运行依赖java jdk,否则运行allure时会报错 下载:java_jdk_1.8.0 allure 作用:allure服务,展示测试报告 下载:allure-commandl 阅读全文
posted @ 2021-12-06 17:44 漓白 阅读(85) 评论(0) 推荐(0) 编辑
摘要:目录:测试自动化学习 - pytest 说明:本篇博客基于pytest 6.2.5 参数化装饰器:@pytest.mark.parametrize("参数", 参数列表, ids=用例命名) import pytest import yaml # 单个参数 @pytest.mark.parametr 阅读全文
posted @ 2021-12-06 17:40 漓白 阅读(111) 评论(0) 推荐(0) 编辑
摘要:目录:测试自动化学习 - pytest 说明:本篇博客基于pytest 6.2.5 总览 范围 | 前置 | 后置 | 代码位置 | 运行规则 :- | :- | :- | :- | :- 模块级 | setup_moudle | teardown_moudle | 模块 | 模块调用时,运行一次 阅读全文
posted @ 2021-12-06 17:31 漓白 阅读(71) 评论(0) 推荐(0) 编辑
摘要:目录:测试自动化学习 - pytest 说明:本篇博客基于pytest 6.2.5 用例标记 添加标签 标记:装饰器@pytest.mark.标记名 添加sikp标记 装饰器跳过:装饰器@pytest.mark.skip(reason="跳过说明") 代码跳过:代码中添加pytest.skip("跳 阅读全文
posted @ 2021-12-06 17:30 漓白 阅读(136) 评论(0) 推荐(0) 编辑
摘要:目录:测试自动化学习 - pytest 说明:本篇博客基于pytest 6.2.5 文件:test_开头、_test结尾 类名:Test 开头 方法/函数:test_开头 pytest运行时,会自动查找符合命名规范的代码,执行用例 注意:文件使用test_了命名后,就不再执行常规python代码 原 阅读全文
posted @ 2021-12-06 17:25 漓白 阅读(101) 评论(0) 推荐(0) 编辑
摘要:目录:测试自动化学习 - pytest 说明:本篇博客基于pytest 6.2.5 python文件:demo.py # content of test_sample.py def inc(x): return x + 1 def test_answer(): assert inc(3) == 5 阅读全文
posted @ 2021-12-06 17:25 漓白 阅读(51) 评论(0) 推荐(0) 编辑
摘要:目录:测试自动化学习 - pytest 说明:本篇博客基于pytest 6.2.5 下载pytest 安装内容:python三方库,使用pip进行安装 pip install pytest 修改pycharm默认执行方式 修改后,pycharm可以识别pytest用例,执行时自动使用pytest运行 阅读全文
posted @ 2021-12-06 17:23 漓白 阅读(73) 评论(0) 推荐(0) 编辑

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