Download presentation
Presentation is loading. Please wait.
Published byArlene Collins Modified over 8 years ago
1
Introduction to Workbot 2.0 Ryan Li Test automation ryan.li@quest.com ant the Cucumber
2
Agenda What’s Cucumber? Why Cucumber? Features What’s BDD Examples Q&A Ryan Li, Test automation, Quest software 2011
3
What’s Cucumber? We can also call it Cuke, is an acceptance testing tool that executes plain-text functional descriptions as automated tests. The language that Cucumber understands is called Gherkin. Types of software testing: http://baike.baidu.com/view/16563.htm Ryan Li, Test automation, Quest software 2011
4
Ryan Li, Test automation, Quest software Test Matrix TypeWhy? UnitDid we build the code right? Does it work as specified? AcceptanceDid we build the right code? Does it do what the user wants? IntegrationDo system components work together? What about performance? SystemIs the system installed and configured correctly? ExploratoryWhat can we find out about the system that is not specified by these tests?
5
What’s Cucumber? A Very Short Introduction to Acceptance Testing Ryan Li, Test automation, Quest software 2011
6
Consider This Test Script A new customer registers The customer places three books in the shopping cart The customer goes to check-out The customer fills in their delivery address (province: Ontario) The system offers free delivery to the customer Ryan Li, Test automation, Quest software 2011
7
Consider This Test Script The system offers free delivery to Ontario customers when they place their first order and their order contains at least three books Ryan Li, Test automation, Quest software 2011
8
Convert to the Tabular Form Ryan Li, Test automation, Quest software 2011 number of booksorder numbership tofree delivery? 31OntarioYes
9
Convert to the Tabular Form Ryan Li, Test automation, Quest software 2011 number of booksorder numbership tofree delivery? 31OntarioYes 21OntarioNo
10
Convert to the Tabular Form Ryan Li, Test automation, Quest software 2011 number of booksorder numbership tofree delivery? 31OntarioYes 21OntarioNo 32OntarioNo
11
Convert to the Tabular Form Ryan Li, Test automation, Quest software 2011 number of booksorder numbership tofree delivery? 31OntarioYes 21OntarioNo 32OntarioNo 31AlbertaNo
12
How To Do It Collaborate: developers business analysts testers product owner Which tool to use is not as important Don’t look up terminology in Wikipedia Ryan Li, Test automation, Quest software 2011
13
Gherkin is the language that Cucumber understands. It is a Business Readable, Domain Specific Language that lets you describe software’s behavior without detailing how that behavior is implemented. Ryan Li, Test automation, Quest software The Gherkin language
14
Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with Cucumber Scenario: Behavior Driven Development with Cucumber Given a desire for higher quality software And a tool that executes feature documentation written in plain text When you watch this presentation Then you will gain an understanding of behavior driven development And see examples of behavior driven development with cucumber And be equipped to integrate Cucumber into your development process Ryan Li, Test automation, Quest software 2011
15
Meets requirements So, you may ask this question: how Gherkin meets our requirements?? Ryan Li, Test automation, Quest software 2011 目的 角色 期望结果 为了( In order to ) 作为( As a ) 预期( Will, Should )
16
Meets requirements In order to keep of track movies that I want to see As a XunleiCanCan’s customer I can add movies to a queue Ryan Li, Test automation, Quest software 2011 value proposition
17
Meets requirements In order to keep of track movies that I want to see As a XunleiCanCan’s customer I can add movies to a queue Ryan Li, Test automation, Quest software 2011 role
18
Meets requirements In order to keep of track movies that I want to see As a XunleiCanCan’s customer I can add movies to a queue Ryan Li, Test automation, Quest software 2011 feature
19
Wroks as expected Now, it’s the time to have a look at our scenarios Cucumber scenariosCucumber scenarios consist of steps, also known as Givens, Whens and Thens* * Cucumber doesn’t technically distinguish between these three kind of steps. However, we strongly recommend that you do! These words have been carefully selected for their purpose, and you should know what the purpose is to get into the BDD mindset. Ryan Li, Test automation, Quest software 2011
20
Given ( 假如 ) The purpose of givens is to put the system in a known state before the user (or external system) starts interacting with the system (in the When steps). Avoid talking about user interaction in givens. If you had worked with usecases, you would call this preconditions. Examples: Create records (model instances) / set up the database state. It’s ok to call into the layer “inside” the UI layer here (in Rails: talk to the models). Log in a user (An exception to the no-interaction recommendation. Things that “happened earlier” are ok). Ryan Li, Test automation, Quest software 2011
21
When ( 当 ) The purpose of When steps is to describe the key action the user performs (or, using Robert C. Martin’s metaphor, the state transition). Examples: Interact with a web page (Webrat/Watir/Selenium interaction etc should mostly go into When steps). Interact with some other user interface element. Developing a library? Kicking off some kind of action that has an observable effect somewhere else. Ryan Li, Test automation, Quest software 2011
22
Then ( 那么 ) The purpose of Then steps is to observe outcomes. The observations should be related to the business value/benefit in your feature description. The observations should also be on some kind of output – that is something that comes out of the system (report, user interface, message) and not something that is deeply buried inside it (that has no business value). Examples: Verify that something related to the Given+When is (or is not) in the output Check that some external system has received the expected message (was an email with specific content sent?) Ryan Li, Test automation, Quest software 2011
23
Wroks as expected Feature: Manage companies In order to keep track of companies A user Should be able to manage companies Scenario: Create a new company Given I am logged in When I create a new company named Acme Then I should see that a company named Acme exists Ryan Li, Test automation, Quest software 2011
24
Wroks as expected features/ companies.feature steps/ company_steps.rb Ryan Li, Test automation, Quest software 2011
25
Given == Setup Given "I am logged in" do user = Factory(:user) visits new_session_path fills_in ‘Login’, :with => user.login fills_in ‘Password’, :with => user.password clicks_button ‘Login’ end Ryan Li, Test automation, Quest software 2011
26
When == Change When "I create a new company named $name" do |name| visits new_company_path fills_in 'Name', :with => name clicks_button 'Create' end When I create a new company named Acme Ryan Li, Test automation, Quest software 2011 variable
27
Then == Outcome Then "I should see that a company named $name exists" do |name| response.body.should =~ Regexp.new(name) end Ryan Li, Test automation, Quest software 2011
28
Using STAF in Cucumber Encapsulate STAF components Require STAF class in step definitions require 'java' require 'jstaf' import "com.ibm.staf.STAFHandle" import "com.ibm.staf.STAFResult" import "com.ibm.staf.STAFMarshallingContext" Ryan Li, Test automation, Quest software 2011
29
Demonstration Ensure the functions of the calculator works properly Ryan Li, Test automation, Quest software
30
Resources Examples with i18n support: https://github.com/cucumber/cucumber/tree/master/examples/i18n http://hackers.lookout.com/2012/09/multilingual-pickles/ Tutorials: https://github.com/cucumber/cucumber/wiki/tutorials-and-related-blog- posts Ryan Li, Test automation, Quest software 2011
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.