最近在看Gauge自动化测试工具,网上也有相关的中文翻译,可见:https://blog.csdn.net/amoscn/article/details/80472143
以Python举例,gauge python自带了套件内部函数
before_step, after_step, before_scenario, after_scenario, before_spec, after_spec, before_suite, after_suite 这些了python 各种环境一样,那执行顺序是怎么样的呢? 我们写下了官方demo的例子来运行一下:@before_step def before_step_hook(): print("before step hook") @after_step def after_step_hook(): print("after step hook") @before_scenario def before_scenario_hook(): print("before scenario hook") @after_scenario def after_scenario_hook(): print("after scenario hook") @before_spec def before_spec_hook(): print("before spec hook") @after_spec def after_spec_hook(): print("after spec hook") @before_suite def before_suite_hook(): print("before suite hook") @after_suite def after_suite_hook(): print("after suite hook")
执行流程如下,画个草图让大家更好理解:
其中,before step和after step和大部分python框架一样,均会在每个用例前及后会执行一次,其它则根据场景或spec或suite分别执行一次