Fork me on GitHub

05 2024 档案

摘要:前言 有的场景setup与teardown无法满足,如:有的用例需要登录才能执行,有的用例不需要登录。 fixture fixture可以满足以上特殊的场景。 1. 只有登录的函数上面加上 @pytest.fixture() 2. 在要使用的测试方法中传入(登录函数名称),就先登录 案例 impor 阅读全文
posted @ 2024-05-14 11:00 测栈云 阅读(7) 评论(0) 推荐(0) 编辑
摘要:前言 测试失败后要重新运行n次,要在重新运行之间添加延迟时间,间隔n秒再运行 安装:pip install pytest-rerunfailures 案例 import pytest class TestDemo: def test_a(self): print("失败用例") assert 1 = 阅读全文
posted @ 2024-05-13 09:59 测栈云 阅读(62) 评论(0) 推荐(0) 编辑
摘要:前言 与unitest一样,python也拥有前置(setup)、后置操作(teardown)操作,而且更加的灵活 setup与teardown介绍 1. 模块级别(setup_module / teardown_module)模块始末,全局的(优先最高)2. 函数级(setup_function 阅读全文
posted @ 2024-05-12 22:33 测栈云 阅读(165) 评论(0) 推荐(0) 编辑

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