Cucumber的语法

上一篇 / 下一篇  2013-01-25 10:47:06 / 个人分类:测试

英文语法:

# language: en
Feature: Addition
  In order to avoid silly mistakes
  As a math idiot 
  I want to be told the sum of two numbers
 
Scenario: case 1 - Add two numbers       
  Given the input "2+2"         
  When the calculator is run    
  Then the output should be "4" 

Scenario Outline: case 2 - Add two numbers     
  Given the input "<input>"            
  When the calculator is run           
  Then the output should be "<output>" 

  Examples:
    | input | output |
    | 2+2   | 4      |
    | 98+1  | 99     |

*But也是常用的关键字
*Given,When,Then,But都可以在一个Scenario里出现一次或者不出现
*Given后的And等同于Given, Then后的And等同于Then

中文语法:

# language: zh-CN
功能:加法
  为了避免一些愚蠢的错误
  作为一个数学白痴
  我希望有人告诉我数字相加的结果

  场景: 两个数相加
    假如我已经在计算器里输入6		#Given
    而且我已经在计算器里输入7		#And(Given)
    我按下相加按钮			#When
    那么我应该在屏幕上看到的结果是13	#Then

  场景大纲: 将两个数相加
    假如我已经在计算器上输入<数值_1>
    而且我已经在计算器上输入<数值_2>
    当我按下 <按钮>
    那么我应该在屏幕上看到<结果>

  例子:
    | 数值_1 | 数值_2  | 按钮  | 结果 |
    | 20     | 30     | add  | 50   |
    | 2      | 5      | add  | 7    |
    | 0      | 40     | add  | 40   |
没有When的
 场景: 两个数相加
    假如我已经在计算器里输入6		#Given
    而且我已经在计算器里输入7		#And(Given)
    而且我按下相加按钮			#And(Given)
    那么我应该在屏幕上看到的结果是13	#Then

TAG: cucumber

 

评分:0

我来说两句

日历

« 2024-04-29  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 151216
  • 日志数: 185
  • 文件数: 6
  • 建立时间: 2007-08-06
  • 更新时间: 2015-01-06

RSS订阅

Open Toolbar