SlideShare a Scribd company logo
1 of 57
Writing runnable acceptance criteria in plain text with Farooq Ali
The Yawning Crevasse of Doom
fluffy high-level needs
<technical_babble />
[Test] [ExpectedException(typeof(InsufficientFundsException))] public void TransferWithInsufficientFunds() { 	Account source = new Account(); 	source.Deposit(200.00F); 	Account destination = new Account(); 	destination.Deposit(150.00F); }
the convergence of two movements
the convergence of two movements Behavior-Driven Development  (BDD) & Domain-Specific Languages (DSLs)
“Acceptance criteria  should be executable” “…a ubiquitous  language for analysis” BDD movement
what are we really trying to describe?
what are we really trying to describe? the human concept of causality
Causality Precondition 	-> 	Given            Action		-> 	When       Outcome		-> 	Then
Causality Setup Data/State 	-> 	Given         Call Method	-> 	When       	   Assert	 	-> 	Then
“…a computer language that's targeted  to a particular kind of problem, rather  than a general purpose language that's  aimed at any kind of software problem.” DSL movement
“The sweet spot, however is in making  DSLs business-readable rather than  business-writeable.” DSL movement
BDD + DSL
Gherkin Feature: Addition As a math moron I want to add two numbers together So that I can better use my scarce brain processing power Scenario: Adding positive numbers together Given I enter 1 into the calculator When I add 1 to it Then the calculator should show 2
Acceptance Criteria
Shared Vocabulary
Documentation
Traceability
Bug Tracking
Using Cucumber
Components Building Blocks Acceptance Criteria (Plain Text) Step Definitions (Ruby)
Acceptance Criteria Acceptance Criteria Feature: Addition As a math moron I want to add two numbers together So that I can better use my scarce brain processing power   Scenario: Adding positive numbers together     Given I enter 1 into the calculator     When I add 1 to it     Then the calculator should show 2
Acceptance Criteria Acceptance Criteria Feature: Addition As a math moron I want to add two numbers together So that I can better use my scarce brain processing power   Scenario: Adding positive numbers together     Given I enter 1 into the calculator     When I add 1 to it     Then the calculator should show 2
Acceptance Criteria Acceptance Criteria Feature: Addition As a math moron I want to add two numbers together So that I can better use my scarce brain processing power   Scenario: Adding positive numbers together     Given I enter 1 into the calculator     When I add 1 to it     Then the calculator should show 2
Acceptance Criteria Acceptance Criteria Feature: Addition As a math moron I want to add two numbers together So that I can better use my scarce brain processing power Scenario: Adding positive numbers together     Given I enter 1 into the calculator     When I add 1 to it     Then the calculator should show 2
Acceptance Criteria Acceptance Criteria Feature: Addition As a math moron I want to add two numbers together So that I can better use my scarce brain processing power   Scenario: Adding positive numbers together Given I enter 1 into the calculator When I add 1 to it Then the calculator should show 2
Keywords Keywords
Languages Languages Macintosh-9:calculator ThoughtWorks$ cucumber --language help | ar     | Arabic                 | العربية | bg     | Bulgarian              | български | cat    | Catalan                | català | cy     | Welsh                  | Cymraeg | cz     | Czech                  | Česky | da     | Danish                 | dansk | de     | German                 | Deutsch                 | en     | English                | English                 | en-au  | Australian             | Australian              | en-lol | LOLCAT                 | LOLCAT                  | en-tx  | Texan                  | Texan                   | es     | Spanish                | español | et     | Estonian               | eesti keel              | fi     | Finnish                | suomi | fr     | French                 | français | he     | Hebrew                 | עברית | hr     | Croatian               | hrvatski | hu     | Hungarian              | magyar | id     | Indonesian             | Bahasa Indonesia
Step Definitions Building Blocks Given I enter 1 into the calculatorWhen I add 1 to itThen the calculator should show 2 Acceptance Criteria (Plain Text)
Step Definitions Building Blocks Given I enter 1 into the calculatorWhen I add 1 to itThen the calculator should show 2 Acceptance Criteria (Plain Text) Given /^I enter (.+) into the calculator$/ do |number|@calculator = Calculator.new@calculator.enter(number.to_i)endWhen /^I add (.+) to it$/ do |number|@calculator.add(number.to_i)endWhen /^the calculator should show (.+)$/ do |number|@calculator.number.should == number.to_iend Step Definitions (Ruby)
Step Definitions Step Definitions Given /^I enter (.+) into the calculator$/ do |number|@calculator = Calculator.new@calculator.enter(number.to_i)endWhen /^I add (.+) to it$/ do |number|@calculator.add(number.to_i)endThen /^the calculator should show (.+)$/ do |number|@calculator.number.should == number.to_iend
Step Definitions Step Definitions Then /^the calculator should show (.+)$/ do |number|@calculator.number.should == number.to_iend
Step Definitions Step Definitions When I give a 45-minute long talk on Cucumber at 10:30am
Step Definitions Step Definitions When I give a 45-minute long talk on Cucumber at 10:30am
Step Definitions Step Definitions When I give a 45-minute long talk on Cucumber at 10:30am /I give a (+)-minute long talk on (.+) at (+):(+)(am|pm)/
Step Definitions Step Definitions When I give a 45-minute long talk on Cucumber at 10:30am /I give a (+)-minute long talk on (.+) at (+):(+)(am|pm)/
Step Definitions Step Definitions When I give a 45-minute long talk on Cucumber at 10:30am /I give a (+)-minute long talk on (.+) at (+):(+)(am|pm)/ do |duration_in_minutes, topic, start_hour, start_minute, am_pm|end
Multiple Given-When-Thens Scenario: Multiple Givens     Given one thing     Given another thing     Given yet another thing     When I open my eyes     Then I see something     Then I don't see something else Multiple Given-When-Thens
Or use And / But Scenario: Multiple Givens     Given one thing  And another thing  And yet another thing     When I open my eyes     Then I see something But I don't see something else Or use And/But
Reuse Calling steps from within steps Given /^the user (.*) exists$/ do |name|#... end Given /^I log in as (.*)$/ do |name|   #... end Given /^(.*) is logged in$/ do |name|   Given "the user #{name} exists"   Given "I log in as #{name}" end
Reuse Multiline step arguments - Tables Given the following people exist:   | name   | email            | phone |   | Farooq | farooq@email.com | 123   |   | Mary   | mary@email.com   | 234   |   | Bob    | bob@email.org    | 456   |
Reuse Multiline step arguments - Tables Given the following people exist:   | name   | email            | phone |   | Farooq | farooq@email.com | 123   |   | Mary   | mary@email.com   | 234   |   | Bob    | bob@email.org    | 456   | Given /the following people exist:/ do |people_table|people_table.hashes.each do |hash|# 1st: {'name' => ’Farooq', 'email' => ’farooq@email.com’, ... }     # 2nd: {'name' => ’Mary', 'email' => ’mary@email.com', ... }    # ...endend
Reuse Multiline step arguments - Strings Given a blog post named "Random" with Markdown body   """   Some Title, Eh?   ==============   Here is the first paragraph of my blog post. Loremipsum dolor sit amet, consecteturadipiscingelit.   """
Reuse Multiline step arguments - Strings Given a blog post named "Random" with Markdown body   """   Some Title, Eh?   ==============   Here is the first paragraph of my blog post. Loremipsum dolor sit amet, consecteturadipiscingelit.   """ Given /^a blog post named "([^quot;]*)" with Markdown body$/ do |title, markdown|Post.create!(:title=> title, :body => markdown)end
Tags Tags @billingFeature: Enter billing info@creditcardScenario: Credit card  	  @paypal   Scenario: PayPal
Hooks Hooks Before do# do something before first step of scenarioendAfter do# do something after each scenarioend
Tagged Hooks Tagged Hooks Before('@billing', '@calculations') do # This will only run before scenarios tagged   # with @billing or @calculations.  end
Global Hooks Global Hooks browser = Selenium::SeleniumDriver.new("localhost", 4444, "*chrome",  										   "http://localhost", 15000) Given 'I am on the Google search page' do browser.open('http://www.google.com/’) end When /I search for "(.*)"/ do |query| browser.type('q', query)    browser.click 'btnG’ browser.wait_for_page_to_load end Then /I should see a link to (.*)/ do |expected_url| browser.is_element_present("css=a[href='#{expected_url}']").should be_true end
Tags Backgrounds Feature: Multiple site support   As a Mephisto site owner   I want to host blogs for different people   In order to make gigantic piles of money  Background:    Given a global administrator named “Greg”    And a blog named “Greg’s anti-tax rants”    And a customer named “Dr. Bill”    And a blog named “Expensive Therapy” owned by “Dr. Bill”  Scenario: Dr. Bill posts to his own blog    Given I am logged in as Dr. Bill    When I try to post to “Expensive Therapy”   Then I should see “Your article was published.”
Global Hooks Step Argument Transforms # support file Transform /^user (+)$/ do |username| User.find_by_username(username)  end # step definition file Then /^(user +) should be friends with (user +)$/ do |user,friend|  user.shouldbe_friends_with(friend) end
Formatters cucumber -fjunit -–out <output_dir>
Formatters: Steps Feature: --formatter steps option - Steps Formatter  In order to easily see which steps are already defined,  specially when using 3rd party steps libraries,  Cucumber should show the available steps in a user-friendly format  Background:    Given I am in steps_library  Scenario: Printing steps    When I run cucumber -f steps features    Then it should pass with    """    features/step_definitions/steps_lib1.rb      /^I defined a first step$/           # features/step_definitions/steps_lib1.rb:1      /^I define a second step$/           # features/step_definitions/steps_lib1.rb:4      /^I should also have a third step$/  # features/step_definitions/steps_lib1.rb:7    features/step_definitions/steps_lib2.rb      /^I defined a step 4$/                # features/step_definitions/steps_lib2.rb:1      /^I create a step 5$/                 # features/step_definitions/steps_lib2.rb:4      /^I should be too tired for step 6$/  # features/step_definitions/steps_lib2.rb:7    6 step definition(s) in 2 source file(s).    """
Formatters : JUnit Feature: JUnit output formatter   In order for developers to create test reports with ant   Cucumber should be able to output JUnit xml files   Background:     Given I am in junit     And the tmp directory is empty   @mri186   Scenario: one feature, one passing scenario, one failing scenario     When I run cucumber --format junit --out tmp/ features/one_passing_one_failing.feature     Then it should fail with       """       """     And "examples/junit/tmp/TEST-one_passing_one_failing.xml" with junit duration "0.005" should contain       """       <?xml version="1.0" encoding="UTF-8"?>       <testsuite errors="0" failures="1" name="One passing scenario, one failing scenario" tests="2" time="0.005">       <testcaseclassname="One passing scenario, one failing scenario.Passing" name="Passing" time="0.005">       </testcase>       <testcaseclassname="One passing scenario, one failing scenario.Failing" name="Failing" time="0.005">         <failure message="failed Failing" type="failed">       Scenario: Failing       Given a failing scenario       Message:        (RuntimeError)       features/one_passing_one_failing.feature:7:in `Given a failing scenario'  </failure>       </testcase>       </testsuite>       """   Scenario: pending steps are simply skipped     When I run cucumber --format junit --out tmp/ features/pending.feature     Then it should pass with       """       """     And "examples/junit/tmp/TEST-pending.xml" with junit duration "0.009" should contain       """       <?xml version="1.0" encoding="UTF-8"?>       <testsuite errors="0" failures="0" name="Pending step" tests="0" time="0.009">       </testsuite>       """   Scenario: pending step with strict option should fail     When I run cucumber --format junit --out tmp/ features/pending.feature --strict     Then it should fail with       """       """     And "examples/junit/tmp/TEST-pending.xml" with junit duration "0.000160" should contain       """       <?xml version="1.0" encoding="UTF-8"?>       <testsuite errors="0" failures="1" name="Pending step" tests="1" time="0.000160">       <testcaseclassname="Pending step.Pending" name="Pending" time="0.000160">         <failure message="pending Pending" type="pending">       Scenario: Pending       TODO (Cucumber::Pending)       features/pending.feature:4:in `Given a pending step'  </failure>       </testcase>       </testsuite>       """   Scenario: run all features     When I run cucumber --format junit --out tmp/ features     Then it should fail with       """       """     And "examples/junit/tmp/TEST-one_passing_one_failing.xml" should exist     And "examples/junit/tmp/TEST-pending.xml" should exist   Scenario: show correct error message if no --out is passed     When I run cucumber --format junit features     Then STDERR should not match        """ can't convert .* into String TypeError       """     And STDERR should match       """ You must specify out DIR for the junit formatter       """
Formatters : HTML Feature: HTML formatter   In order to make it easy to read Cucumber results   there should be a HTML formatter with an awesome CSS   Scenario: Everything in examples/self_test     When I run cucumber -q --format html --out tmp/a.html features     Then "examples/self_test/tmp/a.html" should have the same contents as "features/html_formatter/a.html"

More Related Content

Similar to Cucumber

Executable Requirements with Behaviour-Driven Development and Cucumber - Euro...
Executable Requirements with Behaviour-Driven Development and Cucumber - Euro...Executable Requirements with Behaviour-Driven Development and Cucumber - Euro...
Executable Requirements with Behaviour-Driven Development and Cucumber - Euro...Aslak Hellesøy
 
Dealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottDealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottO'Reilly Media
 
Advanced Perl Techniques
Advanced Perl TechniquesAdvanced Perl Techniques
Advanced Perl TechniquesDave Cross
 
The Power of Composition (NDC Oslo 2020)
The Power of Composition (NDC Oslo 2020)The Power of Composition (NDC Oslo 2020)
The Power of Composition (NDC Oslo 2020)Scott Wlaschin
 
Blocks by Lachs Cox
Blocks by Lachs CoxBlocks by Lachs Cox
Blocks by Lachs Coxlachie
 
Stuart Mitchell - Pulp Optimisation
Stuart Mitchell - Pulp OptimisationStuart Mitchell - Pulp Optimisation
Stuart Mitchell - Pulp Optimisationdanny.adair
 
resolvendo problemas de comunicação em equipes distribuídas com bdd
resolvendo problemas de comunicação em equipes distribuídas com bddresolvendo problemas de comunicação em equipes distribuídas com bdd
resolvendo problemas de comunicação em equipes distribuídas com bddRodrigo Urubatan
 
WCRI 2015 I18N L10N
WCRI 2015 I18N L10NWCRI 2015 I18N L10N
WCRI 2015 I18N L10NDave McHale
 
Perl 6 in Context
Perl 6 in ContextPerl 6 in Context
Perl 6 in Contextlichtkind
 
Migrating to Puppet 4.0
Migrating to Puppet 4.0Migrating to Puppet 4.0
Migrating to Puppet 4.0Puppet
 
The Power Of Composition (DotNext 2019)
The Power Of Composition (DotNext 2019)The Power Of Composition (DotNext 2019)
The Power Of Composition (DotNext 2019)Scott Wlaschin
 
Building Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on GoogleBuilding Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on GooglePeter Friese
 
DC |> Elixir Meetup - Going off the Rails into Elixir - Dan Ivovich
DC |> Elixir Meetup - Going off the Rails into Elixir - Dan IvovichDC |> Elixir Meetup - Going off the Rails into Elixir - Dan Ivovich
DC |> Elixir Meetup - Going off the Rails into Elixir - Dan IvovichSmartLogic
 
Rubyconf2016 - Solving communication problems in distributed teams with BDD
Rubyconf2016 - Solving communication problems in distributed teams with BDDRubyconf2016 - Solving communication problems in distributed teams with BDD
Rubyconf2016 - Solving communication problems in distributed teams with BDDRodrigo Urubatan
 
Tech Days Paris Intoduction F# and Collective Intelligence
Tech Days Paris Intoduction F# and Collective IntelligenceTech Days Paris Intoduction F# and Collective Intelligence
Tech Days Paris Intoduction F# and Collective IntelligenceRobert Pickering
 

Similar to Cucumber (20)

Executable Requirements with Behaviour-Driven Development and Cucumber - Euro...
Executable Requirements with Behaviour-Driven Development and Cucumber - Euro...Executable Requirements with Behaviour-Driven Development and Cucumber - Euro...
Executable Requirements with Behaviour-Driven Development and Cucumber - Euro...
 
Dealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottDealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter Scott
 
Advanced Perl Techniques
Advanced Perl TechniquesAdvanced Perl Techniques
Advanced Perl Techniques
 
Cucumber & BDD
Cucumber & BDDCucumber & BDD
Cucumber & BDD
 
Python slide
Python slidePython slide
Python slide
 
The Power of Composition (NDC Oslo 2020)
The Power of Composition (NDC Oslo 2020)The Power of Composition (NDC Oslo 2020)
The Power of Composition (NDC Oslo 2020)
 
BDD with cucumber
BDD with cucumberBDD with cucumber
BDD with cucumber
 
Blocks by Lachs Cox
Blocks by Lachs CoxBlocks by Lachs Cox
Blocks by Lachs Cox
 
Stuart Mitchell - Pulp Optimisation
Stuart Mitchell - Pulp OptimisationStuart Mitchell - Pulp Optimisation
Stuart Mitchell - Pulp Optimisation
 
resolvendo problemas de comunicação em equipes distribuídas com bdd
resolvendo problemas de comunicação em equipes distribuídas com bddresolvendo problemas de comunicação em equipes distribuídas com bdd
resolvendo problemas de comunicação em equipes distribuídas com bdd
 
WCRI 2015 I18N L10N
WCRI 2015 I18N L10NWCRI 2015 I18N L10N
WCRI 2015 I18N L10N
 
Perl 6 in Context
Perl 6 in ContextPerl 6 in Context
Perl 6 in Context
 
Migrating to Puppet 4.0
Migrating to Puppet 4.0Migrating to Puppet 4.0
Migrating to Puppet 4.0
 
The Power Of Composition (DotNext 2019)
The Power Of Composition (DotNext 2019)The Power Of Composition (DotNext 2019)
The Power Of Composition (DotNext 2019)
 
Modern Perl
Modern PerlModern Perl
Modern Perl
 
Building Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on GoogleBuilding Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on Google
 
DC |> Elixir Meetup - Going off the Rails into Elixir - Dan Ivovich
DC |> Elixir Meetup - Going off the Rails into Elixir - Dan IvovichDC |> Elixir Meetup - Going off the Rails into Elixir - Dan Ivovich
DC |> Elixir Meetup - Going off the Rails into Elixir - Dan Ivovich
 
TDD with PhpSpec
TDD with PhpSpecTDD with PhpSpec
TDD with PhpSpec
 
Rubyconf2016 - Solving communication problems in distributed teams with BDD
Rubyconf2016 - Solving communication problems in distributed teams with BDDRubyconf2016 - Solving communication problems in distributed teams with BDD
Rubyconf2016 - Solving communication problems in distributed teams with BDD
 
Tech Days Paris Intoduction F# and Collective Intelligence
Tech Days Paris Intoduction F# and Collective IntelligenceTech Days Paris Intoduction F# and Collective Intelligence
Tech Days Paris Intoduction F# and Collective Intelligence
 

Recently uploaded

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 

Recently uploaded (20)

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 

Cucumber

  • 1. Writing runnable acceptance criteria in plain text with Farooq Ali
  • 5. [Test] [ExpectedException(typeof(InsufficientFundsException))] public void TransferWithInsufficientFunds() { Account source = new Account(); source.Deposit(200.00F); Account destination = new Account(); destination.Deposit(150.00F); }
  • 6.
  • 7. the convergence of two movements
  • 8. the convergence of two movements Behavior-Driven Development (BDD) & Domain-Specific Languages (DSLs)
  • 9. “Acceptance criteria should be executable” “…a ubiquitous language for analysis” BDD movement
  • 10. what are we really trying to describe?
  • 11. what are we really trying to describe? the human concept of causality
  • 12. Causality Precondition -> Given Action -> When Outcome -> Then
  • 13. Causality Setup Data/State -> Given Call Method -> When Assert -> Then
  • 14. “…a computer language that's targeted to a particular kind of problem, rather than a general purpose language that's aimed at any kind of software problem.” DSL movement
  • 15. “The sweet spot, however is in making DSLs business-readable rather than business-writeable.” DSL movement
  • 17. Gherkin Feature: Addition As a math moron I want to add two numbers together So that I can better use my scarce brain processing power Scenario: Adding positive numbers together Given I enter 1 into the calculator When I add 1 to it Then the calculator should show 2
  • 24. Components Building Blocks Acceptance Criteria (Plain Text) Step Definitions (Ruby)
  • 25. Acceptance Criteria Acceptance Criteria Feature: Addition As a math moron I want to add two numbers together So that I can better use my scarce brain processing power Scenario: Adding positive numbers together Given I enter 1 into the calculator When I add 1 to it Then the calculator should show 2
  • 26. Acceptance Criteria Acceptance Criteria Feature: Addition As a math moron I want to add two numbers together So that I can better use my scarce brain processing power Scenario: Adding positive numbers together Given I enter 1 into the calculator When I add 1 to it Then the calculator should show 2
  • 27. Acceptance Criteria Acceptance Criteria Feature: Addition As a math moron I want to add two numbers together So that I can better use my scarce brain processing power Scenario: Adding positive numbers together Given I enter 1 into the calculator When I add 1 to it Then the calculator should show 2
  • 28. Acceptance Criteria Acceptance Criteria Feature: Addition As a math moron I want to add two numbers together So that I can better use my scarce brain processing power Scenario: Adding positive numbers together Given I enter 1 into the calculator When I add 1 to it Then the calculator should show 2
  • 29. Acceptance Criteria Acceptance Criteria Feature: Addition As a math moron I want to add two numbers together So that I can better use my scarce brain processing power Scenario: Adding positive numbers together Given I enter 1 into the calculator When I add 1 to it Then the calculator should show 2
  • 31. Languages Languages Macintosh-9:calculator ThoughtWorks$ cucumber --language help | ar | Arabic | العربية | bg | Bulgarian | български | cat | Catalan | català | cy | Welsh | Cymraeg | cz | Czech | Česky | da | Danish | dansk | de | German | Deutsch | en | English | English | en-au | Australian | Australian | en-lol | LOLCAT | LOLCAT | en-tx | Texan | Texan | es | Spanish | español | et | Estonian | eesti keel | fi | Finnish | suomi | fr | French | français | he | Hebrew | עברית | hr | Croatian | hrvatski | hu | Hungarian | magyar | id | Indonesian | Bahasa Indonesia
  • 32. Step Definitions Building Blocks Given I enter 1 into the calculatorWhen I add 1 to itThen the calculator should show 2 Acceptance Criteria (Plain Text)
  • 33. Step Definitions Building Blocks Given I enter 1 into the calculatorWhen I add 1 to itThen the calculator should show 2 Acceptance Criteria (Plain Text) Given /^I enter (.+) into the calculator$/ do |number|@calculator = Calculator.new@calculator.enter(number.to_i)endWhen /^I add (.+) to it$/ do |number|@calculator.add(number.to_i)endWhen /^the calculator should show (.+)$/ do |number|@calculator.number.should == number.to_iend Step Definitions (Ruby)
  • 34. Step Definitions Step Definitions Given /^I enter (.+) into the calculator$/ do |number|@calculator = Calculator.new@calculator.enter(number.to_i)endWhen /^I add (.+) to it$/ do |number|@calculator.add(number.to_i)endThen /^the calculator should show (.+)$/ do |number|@calculator.number.should == number.to_iend
  • 35. Step Definitions Step Definitions Then /^the calculator should show (.+)$/ do |number|@calculator.number.should == number.to_iend
  • 36. Step Definitions Step Definitions When I give a 45-minute long talk on Cucumber at 10:30am
  • 37. Step Definitions Step Definitions When I give a 45-minute long talk on Cucumber at 10:30am
  • 38. Step Definitions Step Definitions When I give a 45-minute long talk on Cucumber at 10:30am /I give a (+)-minute long talk on (.+) at (+):(+)(am|pm)/
  • 39. Step Definitions Step Definitions When I give a 45-minute long talk on Cucumber at 10:30am /I give a (+)-minute long talk on (.+) at (+):(+)(am|pm)/
  • 40. Step Definitions Step Definitions When I give a 45-minute long talk on Cucumber at 10:30am /I give a (+)-minute long talk on (.+) at (+):(+)(am|pm)/ do |duration_in_minutes, topic, start_hour, start_minute, am_pm|end
  • 41. Multiple Given-When-Thens Scenario: Multiple Givens Given one thing Given another thing Given yet another thing When I open my eyes Then I see something Then I don't see something else Multiple Given-When-Thens
  • 42. Or use And / But Scenario: Multiple Givens Given one thing And another thing And yet another thing When I open my eyes Then I see something But I don't see something else Or use And/But
  • 43. Reuse Calling steps from within steps Given /^the user (.*) exists$/ do |name|#... end Given /^I log in as (.*)$/ do |name| #... end Given /^(.*) is logged in$/ do |name| Given "the user #{name} exists" Given "I log in as #{name}" end
  • 44. Reuse Multiline step arguments - Tables Given the following people exist: | name | email | phone | | Farooq | farooq@email.com | 123 | | Mary | mary@email.com | 234 | | Bob | bob@email.org | 456 |
  • 45. Reuse Multiline step arguments - Tables Given the following people exist: | name | email | phone | | Farooq | farooq@email.com | 123 | | Mary | mary@email.com | 234 | | Bob | bob@email.org | 456 | Given /the following people exist:/ do |people_table|people_table.hashes.each do |hash|# 1st: {'name' => ’Farooq', 'email' => ’farooq@email.com’, ... } # 2nd: {'name' => ’Mary', 'email' => ’mary@email.com', ... } # ...endend
  • 46. Reuse Multiline step arguments - Strings Given a blog post named "Random" with Markdown body """ Some Title, Eh? ============== Here is the first paragraph of my blog post. Loremipsum dolor sit amet, consecteturadipiscingelit. """
  • 47. Reuse Multiline step arguments - Strings Given a blog post named "Random" with Markdown body """ Some Title, Eh? ============== Here is the first paragraph of my blog post. Loremipsum dolor sit amet, consecteturadipiscingelit. """ Given /^a blog post named "([^quot;]*)" with Markdown body$/ do |title, markdown|Post.create!(:title=> title, :body => markdown)end
  • 48. Tags Tags @billingFeature: Enter billing info@creditcardScenario: Credit card @paypal Scenario: PayPal
  • 49. Hooks Hooks Before do# do something before first step of scenarioendAfter do# do something after each scenarioend
  • 50. Tagged Hooks Tagged Hooks Before('@billing', '@calculations') do # This will only run before scenarios tagged # with @billing or @calculations. end
  • 51. Global Hooks Global Hooks browser = Selenium::SeleniumDriver.new("localhost", 4444, "*chrome", "http://localhost", 15000) Given 'I am on the Google search page' do browser.open('http://www.google.com/’) end When /I search for "(.*)"/ do |query| browser.type('q', query) browser.click 'btnG’ browser.wait_for_page_to_load end Then /I should see a link to (.*)/ do |expected_url| browser.is_element_present("css=a[href='#{expected_url}']").should be_true end
  • 52. Tags Backgrounds Feature: Multiple site support As a Mephisto site owner I want to host blogs for different people In order to make gigantic piles of money Background: Given a global administrator named “Greg” And a blog named “Greg’s anti-tax rants” And a customer named “Dr. Bill” And a blog named “Expensive Therapy” owned by “Dr. Bill” Scenario: Dr. Bill posts to his own blog Given I am logged in as Dr. Bill When I try to post to “Expensive Therapy” Then I should see “Your article was published.”
  • 53. Global Hooks Step Argument Transforms # support file Transform /^user (+)$/ do |username| User.find_by_username(username) end # step definition file Then /^(user +) should be friends with (user +)$/ do |user,friend| user.shouldbe_friends_with(friend) end
  • 54. Formatters cucumber -fjunit -–out <output_dir>
  • 55. Formatters: Steps Feature: --formatter steps option - Steps Formatter In order to easily see which steps are already defined, specially when using 3rd party steps libraries, Cucumber should show the available steps in a user-friendly format Background: Given I am in steps_library Scenario: Printing steps When I run cucumber -f steps features Then it should pass with """ features/step_definitions/steps_lib1.rb /^I defined a first step$/ # features/step_definitions/steps_lib1.rb:1 /^I define a second step$/ # features/step_definitions/steps_lib1.rb:4 /^I should also have a third step$/ # features/step_definitions/steps_lib1.rb:7 features/step_definitions/steps_lib2.rb /^I defined a step 4$/ # features/step_definitions/steps_lib2.rb:1 /^I create a step 5$/ # features/step_definitions/steps_lib2.rb:4 /^I should be too tired for step 6$/ # features/step_definitions/steps_lib2.rb:7 6 step definition(s) in 2 source file(s). """
  • 56. Formatters : JUnit Feature: JUnit output formatter In order for developers to create test reports with ant Cucumber should be able to output JUnit xml files Background: Given I am in junit And the tmp directory is empty @mri186 Scenario: one feature, one passing scenario, one failing scenario When I run cucumber --format junit --out tmp/ features/one_passing_one_failing.feature Then it should fail with """ """ And "examples/junit/tmp/TEST-one_passing_one_failing.xml" with junit duration "0.005" should contain """ <?xml version="1.0" encoding="UTF-8"?> <testsuite errors="0" failures="1" name="One passing scenario, one failing scenario" tests="2" time="0.005"> <testcaseclassname="One passing scenario, one failing scenario.Passing" name="Passing" time="0.005"> </testcase> <testcaseclassname="One passing scenario, one failing scenario.Failing" name="Failing" time="0.005"> <failure message="failed Failing" type="failed"> Scenario: Failing Given a failing scenario Message: (RuntimeError) features/one_passing_one_failing.feature:7:in `Given a failing scenario' </failure> </testcase> </testsuite> """ Scenario: pending steps are simply skipped When I run cucumber --format junit --out tmp/ features/pending.feature Then it should pass with """ """ And "examples/junit/tmp/TEST-pending.xml" with junit duration "0.009" should contain """ <?xml version="1.0" encoding="UTF-8"?> <testsuite errors="0" failures="0" name="Pending step" tests="0" time="0.009"> </testsuite> """ Scenario: pending step with strict option should fail When I run cucumber --format junit --out tmp/ features/pending.feature --strict Then it should fail with """ """ And "examples/junit/tmp/TEST-pending.xml" with junit duration "0.000160" should contain """ <?xml version="1.0" encoding="UTF-8"?> <testsuite errors="0" failures="1" name="Pending step" tests="1" time="0.000160"> <testcaseclassname="Pending step.Pending" name="Pending" time="0.000160"> <failure message="pending Pending" type="pending"> Scenario: Pending TODO (Cucumber::Pending) features/pending.feature:4:in `Given a pending step' </failure> </testcase> </testsuite> """ Scenario: run all features When I run cucumber --format junit --out tmp/ features Then it should fail with """ """ And "examples/junit/tmp/TEST-one_passing_one_failing.xml" should exist And "examples/junit/tmp/TEST-pending.xml" should exist Scenario: show correct error message if no --out is passed When I run cucumber --format junit features Then STDERR should not match """ can't convert .* into String TypeError """ And STDERR should match """ You must specify out DIR for the junit formatter """
  • 57. Formatters : HTML Feature: HTML formatter In order to make it easy to read Cucumber results there should be a HTML formatter with an awesome CSS Scenario: Everything in examples/self_test When I run cucumber -q --format html --out tmp/a.html features Then "examples/self_test/tmp/a.html" should have the same contents as "features/html_formatter/a.html"

Editor's Notes

  1. This is something that developers who test are very familiar with from unit testing
  2. This is something that developers who test are very familiar with from unit testing
  3. ericevans ubiquitous language
  4. over 30 spoken languages show languages.yml
  5. demonstrate use of cucumber –tags @arithmetic
  6. demonstrate use of cucumber –tags @arithmetic