python-3.x - python 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.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()
推荐阅读
- ios - 在用户允许访问照片库之前弹出“已保存照片”警报?
- selenium - 探索 Page Factory @FindAll List 的流畅等待机制
连同 AjaxElementLocatorFactory - javascript - 使用带有数字问题的正则表达式拆分字符串
- javascript - Gapi.client.drive.files.update() 返回错误“解析错误”
- python - 对嵌入在字符串列表中的数字进行排序
- android - 为什么 Kotlin 中的一些 GlobalScope.launch 调用的内容静默无法执行?
- c# - c#中的光标位置
- c# - 在 C# UWP 中使用 PublisherSocket 发布消息在 python 中未收到
- javascript - AngularJS 跟踪控制器中的全局变量变化
- python - keras cnn 模型仅预测所有测试图像的一类