摘要: 1,基本请求 测试计划--线程组--采样器(http请求)--监听器(观察结果树) 2,参数化数据请求(csv文件) 添加一个循环控制器,线程组--add--逻辑控制--循环控制,设置循环的次数,注意0为只运行一次,1为2次,以此类推 在循环控制下,添加采样器,在添加CSV文件参数(采样器--add 阅读全文
posted @ 2020-08-27 16:02 myy2 阅读(59) 评论(0) 推荐(0) 编辑
摘要: 1,pytest.approx 判断2个数字在一定范围内的差异中是相等的,也就是解决0.1+0.2不等于0.3的问题 正常来说0.1+0.2不等于0.3, import pytest if __name__ == '__main__': print(0.1 + 0.2 == 0.3) ##false 阅读全文
posted @ 2020-08-25 15:37 myy2 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 完整的参数 API Reference 使用pytest --markers 1,usefixtures @pytest.mark.usefixtures("cleandir", "anotherfixture") def test(): 2,parametrize 直接传入参数/把参数组合/对参数 阅读全文
posted @ 2020-08-19 18:07 myy2 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 1,放到fixture中 2,使用第三方插件 pytest-datadir and pytest-datafiles 3,放到文件中 阅读全文
posted @ 2020-08-17 11:43 myy2 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 1,fixture是依赖注入的一种形式 2,fixture的发现先后规则为:测试类,测试模块,coftest,内置,第三方 多个fixture的运行先后顺序:作用范围越高,越先运行,autouse的优先级高于非autouse的,有依赖的fixture先运行依赖的fixtue,按照注入的先后顺序执行 阅读全文
posted @ 2020-08-17 11:38 myy2 阅读(372) 评论(0) 推荐(0) 编辑
摘要: 1,安装allure brew install allure 因为网速慢导致安装失败,可以尝试下面的方法, https://blog.csdn.net/chenmiao207/article/details/104994194 2,安装allure-pytest pip3 install allur 阅读全文
posted @ 2020-08-03 10:47 myy2 阅读(224) 评论(0) 推荐(0) 编辑
摘要: 完整:ini中的参数设置 Configuration Options 1,格式 [pytest] log_format = %(asctime)s %(levelname)s %(message)s log_date_format = %Y-%m-%d %H:%M:%S 2,addopts 添加运行 阅读全文
posted @ 2020-08-03 09:26 myy2 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 1,capfd/capfdbinary/capsys/capsysbinary 对标准输出和错误输出进行捕获,转化为text或者b字节 2, caplog 动态设置日志的级别,和获取日志的输出内容 caplog.text caplog.set_level 3,cache. (可以用来做用例之间的数据 阅读全文
posted @ 2020-07-31 18:47 myy2 阅读(211) 评论(0) 推荐(0) 编辑
摘要: 使用 python3 -m pytest 用例路径 cmd = 'python3 -m pytest /Users/admin/PycharmProject/test/pytest_dir1' os.system(cmd) 阅读全文
posted @ 2020-07-31 17:18 myy2 阅读(458) 评论(0) 推荐(0) 编辑
摘要: 1,with.....pytest.raise 发生指定的错误信息时,不中断测试(预期内的错误,不做用例失败处理) 可以使用正则进行匹配 2,自定义断言的显示信息 使用hook函数,pytest_assertrepr_compare # 在conftest.py中写def pytest_assert 阅读全文
posted @ 2020-07-31 16:32 myy2 阅读(155) 评论(0) 推荐(0) 编辑