【问题标题】:python bdd framework: How to execute a code before and after steppython bdd框架:如何在步骤前后执行代码
【发布时间】:2020-10-14 23:47:25
【问题描述】:
我很想在 python 中的一步之前和之后实现功能性
Scenario: Addition
Given Calculator app is run
When I input "2+3" to calculator
Then I get result "5"
我希望在执行第二步之前执行一个功能。我该如何继续?
【问题讨论】:
标签:
python-3.x
bdd
python-behave
pytest-bdd
【解决方案1】:
environment.py 文件可用于此:
features/environment.py
def before_step(context, step):
if <some logic to determine which step this is>:
do_something_before_step()
def after_step(context, step):
if <some logic to determine which step this is>:
do_something_after_step()