095-自动化测试框架Cucumber

 

095-自动化测试框架Cucumber

 

 


BDD
Behavior Driven Development
1.Describes overall behaviors of the system
2.customer focused

 

ATDD
Acceptance Test Driven Development
1.Defines tests which act as requirements for the system
2.Development focused

 

 


Gherkin
1.Gherkin is the language Cucumber uses to define test cases
2.Non-technical
3.Human readable
4.Helps enforce firm, unambiguous requirements

 

Keywords
Given ...
And ...
When ...
And ...
Then ...

 

 

Cucumber
1.Open source tool for test automation
2.Tests are written in Gherkin
3.Uses regular expressions to match Gherkin to a cucumber step
4.Cucumber step is what wraps the automation code
5.Cucumber has implementations in :
    Ruby,Java,Javascript...

 

 


举例Example

Feature: The create account page should have verification on all the fields
Scenario: Error message should become visible when I try to submit the account creation form without a name
Given I am on the site homepage
When I click on "sign in link" on the "Home" page
And I click on "register" on the "Sign In" page
...
Then the "missing name error" on the "Create Account" page should be visible

 

 


What is Gherkin?
Real World Example

Given I am on the homepage
When I login as "gherkin_test"
And I navigate to the "My Account" page
And I click on the "My Lists" element on the "My Account" Page
Then I should be on the "My Lists" page

 

 

 

Gherkin:
Scenario Outline
Scenario will run as a unique scenario for each line in it's examples table

 

 

 


Gherkin:
Scenario Outline

Feature: Amazon create account page should have verification on all the fields
Scenario Outline: All of the fields should display an error when not populated on form submission
And I click on "submit" on the "Create Account" Page
Then the "<error>" on the "Create Account" Page should be "visible"

Examples:
| error
| missing name error
| missing email error

 

 

 

 

Feature: Amazon create account page should have verification on all the fields

Scenario Outline: All of the fields should display an error when not populated on form submission
Given I am using the "<user_data>"
And I click on "submit" on the "Create Account" Page
Then the "<error>" on the "Create Account" Page should be "visible"

Examples:
|user_data|error            |
|user1    |missing name error        |
|user2    |missing email error        |
|user3    |missing password error    |

 

 

 


Gherkin:
Steps Table

Scenario outlines
Example Table---Loop full scenario for each row

Step Table---All data is used in at once

 

 

 

 

Gherkin:
Steps Table

Feature: Amazon search results should contain all required data
Scenario Outline: Description of scenario outline
Given I am on the site homepage
When search for "<search_string>"
Then each result should have the following information:
| information  | data_type |
| title               | string       |
| price             | currency   |

Examples:
| search_string |
| cucumber book |
| java book     |

 

 

 


Gherkin:
Background

Feature: Insert detailed description here

Background: Insert background description here
Given I sign in as "user1"

Scenario: Examples 1
When I click on "My Account" on the "Home" Page
Then I should be on the "My Account" Page

Scenario: Example 2
When I click on "Log out" on the "Home" Page
Then I should be on the "Login" Page

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值