Hook 方法之 pytest_runtest_protocol:
pytest_runtest_protocol :
官方给的解释是:为给定的测试项目执行runtest_setup / call / teardown协议;
可以在执行每个测试用例的各个阶段进行钩子拦截,比如在测试用例开始执行前、执行中间某一步骤、执行完成后等,从而可以方便地进行一些额外的操作或者扩展功能。
pytest 的默认 pytest_runtest_protocol 实现会按顺序执行以下操作:
- 调用
pytest_runtest_logstart钩子,标记测试开始 - 调用
pytest_runtest_setup钩子,执行测试前置条件 - 调用
pytest_runtest_call钩子,执行测试函数本身 - 调用
pytest_runtest_teardown钩子,执行测试后置清理 - 调用
pytest_runtest_logfinish钩子,标记测试结束
The default runtest protocol is this (see individual hooks for full details):
-
pyt
订阅专栏 解锁全文
9962

被折叠的 条评论
为什么被折叠?



