什么Cherkin
Gherkin的语法和关键字
关键字
主要关键字
- Feature //特性,每个Gherkin的文件都必须使用Feature开头
- Rule(as of Gherkin 6)
- -Example (or Scenario)
- Scenario //场景
- Given //给定条件
- When //当…时候
- Then //结果
- And //然后
- But //但是
- Background //背景
- Scenario Outline (or Scenario Template) //与Examples配合使用
- Examples //例子
次要的关键字:
- “”” (Doc Strings)
- | (Data Tables)
- @(Tags)
- #(Comments)
语法要求总结
不一定全,自己的学习过程总结
- 不是空行的每一行都必须以Cherkin的关键字开头,然后是您喜欢的任何文本。feature后面可以有多行的描述文本,不做限制
- 可以使用空格或制表符进行缩进。推荐的缩进级别是两个空格。
- 注释行在文件的任何地方都是允许的。它们以零或多个空格开始,然后是一个散列符号(#)和一些文本。注释必须从新的一行开始。
- 一个.feature文件只能有一个feature关键字
- 我用的Gherkin 5,支持Rule关键字,但是必须有Scenario关键字。语法仅使用Rule和Example 搭配不支持。按照文档Gherkin 6应该是支持的
例子
Feature: Highlander This is for test Rule: There can be only One Scenario: Only One -- More than one alive Given there are 3 ninjas And there are more than one ninja alive When 2 ninjas meet, they will fight Then one ninja dies And there is one ninja less alive
Feature: Is it Friday yet? EveryBody wants to know when it's Friday Scenario Outline: Sunday isn't Friday Given today is "
"
* I ask whether it's Friday yet * I should be told "
"
Examples: | day | answer | | Friday | TGIF | | Sunday | Nope | | anything else! | Nope |
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/225591.html原文链接:https://javaforall.net
