Python 3.x PythonBDD框架:如何在步骤前后执行代码
在python中,我正在尝试在一个步骤之前和之后实现函数性Python 3.x PythonBDD框架:如何在步骤前后执行代码,python-3.x,bdd,python-behave,pytest-bdd,Python 3.x,Bdd,Python Behave,Pytest Bdd,在python中,我正在尝试在一个步骤之前和之后实现函数性 Scenario: Addition Given Calculator app is run When I input "2+3" to calculator Then I get result "5" 我希望在执行第二步之前执行一个函数。如何继续?可以使用environment.py文件执行以下操作: features/environment.p
Scenario: Addition
Given Calculator app is run
When I input "2+3" to calculator
Then I get result "5"
我希望在执行第二步之前执行一个函数。如何继续?可以使用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()