際際滷

際際滷Share a Scribd company logo
Cucumber :
Introduction
May 21, 2017
Aditya Chourasiya
Quality Assurance
Business Analysts
Product Owners
Audience
Objective
Presentation is mostly covering my experience and findings on Cucumber. I will try to
keep it as much on discussion mode as possible, however there is definite time for
discussion after each section for it.
Please go through the prerequisites in next slide before the presentation.
Prerequisites
Read about Gherkin here
Behaviour Driven Development[BDD]
Test Driven Development [TDD]
Acceptance Test Driven Dev[ATDD]
Install Chocolatey
5 mins
Definitions
10 mins
Discussion on Definitions
20 mins
Hands on
25 mins
Hands on Discussion
30 mins
Discussion for next
Presentation - Robot
Framework
Lets begin!
What is Test Driven Development [TDD]
Useful in short development life cycle
Widely accepted in XP / Agile
More Developer facing
commonly applied structure
(1) setup > (2) execution > (3) validation >(4) cleanup
They are usually in form of integration tests.
Ex. Code for calculator
Function 1 : Addition
Test : 1+1=2
Function 2 : Multiplication
What is Acceptance Test Driven Development
[ATDD]Acceptance tests are a part of an overall testing strategy. They
are the customer tests that demonstrate the business intent of a
system. Component tests are technical acceptance tests
developed by an architect that specify the behavior of large
modules.
What is Behaviour Driven Development [BDD]
It defines application behaviour in plain
meaningful English text using a simple
grammar.
Gherkin
Ruby community has many great tool for testing, one of
early test framework was RSpec. However due to
limitations it was evolved as cucumber.
In real life gherkin is a variety of cucumber but in
current context Gherkin is the language that Cucumber
understands.
Tags: Feature, Scenario, Scenario outline
Steps: Given-When-Then, And , But, Or
Hook: Before, After , Around
Feature: LogIn Action Test
Description: This feature will test a LogIn and LogOut
functionality
Scenario: Unsuccessful Login with InValid Credentials
Given User is on Home Page
When User Navigate to LogIn Page
And User enters UserName and Password
But The user credentials are wrong
Then Message displayed Wrong UserName &
Password
Discussion
on
Definitions
5min
Prerequisites for hands-on
Cmd admin mode and type
choco install ruby
choco install ruby2.devkit
choco install chromedriver
choco install ansicon
Start command prompt with ruby and type
Gem install watir
Gem install rspec
Gem install cucumber
Gem install colorize
References:
http://www.guru99.com/cucumber-installation.html
Files in Cucumber
Remember to create 2 Files 
Features and Step Definition
Features file contain high level description of the
test scenario in simple language
Steps Definition file contains the actual code to
execute the test scenario in the Features file.
Your structure looks like:
--/features test.feature ---/step_definitions test.rb
To run this feature type in command line:
cucumber test.feature -r step_definitions
Example of Features
Feature: search aditya chourasiya on google
Scenario : Visit google.com and search aditya
Given: I am on google.com
When: I type aditya
And: I click search
Then: I should see my linkedin in result page
Example of Step Definition
Step 1:
Given (/^ I am on google.com$/) do
Browser.goto "http://google.com" -To go to google
Browser.click "" -To go to google
end
Demo
Thank You !
-AdiChourasiya

More Related Content

Cucumber

  • 1. Cucumber : Introduction May 21, 2017 Aditya Chourasiya
  • 3. Objective Presentation is mostly covering my experience and findings on Cucumber. I will try to keep it as much on discussion mode as possible, however there is definite time for discussion after each section for it. Please go through the prerequisites in next slide before the presentation.
  • 4. Prerequisites Read about Gherkin here Behaviour Driven Development[BDD] Test Driven Development [TDD] Acceptance Test Driven Dev[ATDD] Install Chocolatey
  • 5. 5 mins Definitions 10 mins Discussion on Definitions 20 mins Hands on 25 mins Hands on Discussion 30 mins Discussion for next Presentation - Robot Framework
  • 7. What is Test Driven Development [TDD] Useful in short development life cycle Widely accepted in XP / Agile More Developer facing commonly applied structure (1) setup > (2) execution > (3) validation >(4) cleanup They are usually in form of integration tests. Ex. Code for calculator Function 1 : Addition Test : 1+1=2 Function 2 : Multiplication
  • 8. What is Acceptance Test Driven Development [ATDD]Acceptance tests are a part of an overall testing strategy. They are the customer tests that demonstrate the business intent of a system. Component tests are technical acceptance tests developed by an architect that specify the behavior of large modules.
  • 9. What is Behaviour Driven Development [BDD] It defines application behaviour in plain meaningful English text using a simple grammar.
  • 10. Gherkin Ruby community has many great tool for testing, one of early test framework was RSpec. However due to limitations it was evolved as cucumber. In real life gherkin is a variety of cucumber but in current context Gherkin is the language that Cucumber understands. Tags: Feature, Scenario, Scenario outline Steps: Given-When-Then, And , But, Or Hook: Before, After , Around Feature: LogIn Action Test Description: This feature will test a LogIn and LogOut functionality Scenario: Unsuccessful Login with InValid Credentials Given User is on Home Page When User Navigate to LogIn Page And User enters UserName and Password But The user credentials are wrong Then Message displayed Wrong UserName & Password
  • 12. Prerequisites for hands-on Cmd admin mode and type choco install ruby choco install ruby2.devkit choco install chromedriver choco install ansicon Start command prompt with ruby and type Gem install watir Gem install rspec Gem install cucumber Gem install colorize References: http://www.guru99.com/cucumber-installation.html
  • 13. Files in Cucumber Remember to create 2 Files Features and Step Definition Features file contain high level description of the test scenario in simple language Steps Definition file contains the actual code to execute the test scenario in the Features file. Your structure looks like: --/features test.feature ---/step_definitions test.rb To run this feature type in command line: cucumber test.feature -r step_definitions Example of Features Feature: search aditya chourasiya on google Scenario : Visit google.com and search aditya Given: I am on google.com When: I type aditya And: I click search Then: I should see my linkedin in result page Example of Step Definition Step 1: Given (/^ I am on google.com$/) do Browser.goto "http://google.com" -To go to google Browser.click "" -To go to google end
  • 14. Demo

Editor's Notes

  1. Benefits: By focusing on the test cases first, functionality used by clients is clear to team. Used in conjunction with a version control system, when tests fail unexpectedly, reverting the code to the last version that passed all tests However does not perform sufficient functional tests
  2. It is a collaborative practice where users, testers, and developers define automated acceptance criteria. ATDD helps to ensure that all project members understand precisely what needs to be done and implemented. Failing tests provide quick feedback that the requirements are not being met. The tests are specified in business domain terms.
  3. BDD focuses on the behaviors of your system exhibits than the implementation details of it.
  4. .feature files can be considered a method invocation. Before Cucumber can execute a step it must be told, via a step definition, how that step should be performed.