@Author : Terry.Lee
@Time : 2019-10-24 12:16
pip3 install behave
behave --lang-help zh-CN
Translations for Chinese simplified / 简体中文And: 而且<Background: 背景But: 但是<Examples: 例子Feature: 功能Given: 假如<Scenario: 场景
Scenario Outline: 场景大纲Then: 那么<When: 当<
__all__ = ["given", "when", "then", "step", # 首选的写法"Given", "When", "Then", "Step" # 同样支持这种写法
]
[Given]
在用户或外部系统对被测系统做交互之前,使被测系统处于一个可知的状态。在givens中要避免涉及用户交互的操作。
在use case中,givens可以被理解为前置条件precondition。也可以在Given中使用table来设置一些数据
[When]
描述用户或外部系统施展的关键行为。这个交互行为会引起系统状态的变化
[Then]
观察结果。这个观察的结果应该与feature描述的用户价值business value/benefit相关联。这个结果也应该是一个系统产生的
具体的结果而不是对用户不可见,埋藏得很深的结果。对用户不可见的结果也许会没有business value。比如我们应该多验证用户看得见的结果而不是去数据库里面找结果
注: [and]和[but]会被当做when/given/then的一部分来执行。比如一个and属于given step下,那么and这个step就会变为given的一部分
before_step(context, step), after_step(context, step)
# 夹心饼干,步骤"step"相当于中间的奶油,顺序: before_step > step > after_stepbefore_scenario(context, scenario), after_scenario(context, scenario)
# 汉堡包,场景"scenario"相当于中间的食材,顺序: before_scenario > scenario > after_scenariobefore_feature(context, feature), after_feature(context, feature)
# 大夹心饼干,在每个feature文件包含很多的步骤,就像有很多层奶油,顺序: before_feature > feature > after_featurebefore_tag(context, tag), after_tag(context, tag)
# 小蜜蜂,有tag装饰(花)的每个场景前后执行,顺序: before_tag > 被tag装饰的场景 > after_tagbefore_all(context), after_all(context)
# 安检员,在你旅程开始和结束时运行,顺序: before_all > 整个测试过程 > after_all
before_all
for feature in all_features:before_featurefor outline in feature.scenarios:for scenario in outline.scenarios:before_scenariofor step in scenario.steps:before_stepstep.run()after_stepafter_scenarioafter_feature
after_all
本文发布于:2024-02-02 01:51:05,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170681373540641.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |