Gauge your BDD Tests
vodQA Hyderabad 2015
Shivaling
Apoorva M
Mahendra Kariya
Agenda
● Discussion about BDD (15 mins)
● Hands-on workshop (75 mins)
● Advanced Features Demo (15 mins)
● Q & A (15 mins)
#vodqa
#thoughtworks
@getgauge
What is TDD?
Test-driven development (TDD) is a technique for
building software that guides software development by
writing tests first.
- Martin Fowler
TDD (Contd…)
● Req: Calculation engine to be able to add 2 numbers
● Tests
○ @Test
shouldAddPositiveNumbers() {
assertEquals(calculator.add(1, 2), 3);
}
○ @Test
shouldAddNegativeNumbers() {
assertEquals(calculator.add(-1, -2), -3);
}
○ @Test
shouldAddNumbersInWords(){
assertEquals(calculator.add(“one”, “two”), 3);
}
So, BDD then?
People are moving towards BDD
But what is BDD?
When asked what is BDD
● It’s just TDD right?
● That Given-When-Then thing
● Business driven development
● The BA/PO writes the requirements and then the devs
write tests
A collaborative way to define what behaviour in a system
should be tested, by using the same language (natural
language) and grammar used to capture the business need.
BDD is...
The Requirement
As a [Role]
I want [Feature]
So that I receive [Value]
As an online shopper
I want to search for products
So that I can make buying decision
The Test
Given [Context]
When [Event Occurs]
Then [Outcome]
Given that I have logged in
When I search for a product
Then list of related items are displayed
A Badly Written Test
Given that I am on the home page
When I click on the “login” link
And I type text “Mahendra” in the “name” text box
And I type “pwd” in the “password” text box
And I click the “login” button
Then I can see my profile
A Well Written Test
Given I land on the homepage
When I log into my account with username “Mahendra” and
password “pwd”
Then I am on the “profile” page
Another Well Written Test
● Open Home Page
● Login with with username “Mahendra” and password
“pwd”
● “Profile” page is displayed
Popular BDD testing frameworks
● Cucumber (https://cucumber.io)
● Jasmine (http://jasmine.github.io)
● JBehave (http://jbehave.org)
● Concordian (http://concordion.org)
● easyb (http://easyb.org)
In a tool we want...
● Simplicity
because who doesn’t like simple!!
● Maintainability
because everyone has been on a long running project and we
know it is hell to keep tests working
● Customisability
because we all have our own preferences
● Speed
because we all have that need for speed
What if we want to break away from every form of
syntax and write specifications in natural
language?
Like you’d write an email
http://getgauge.io
About Gauge
● Open Source
● Simple Markdown syntax
● Multiple Language Support (Java, C#, Ruby)
● First class parallel execution support
● Extensible and Hackable
● IDE support (IntelliJ, VS, Eclipse)
● First class CI / CD integration support
Hands - on Workshop
Advanced Features Demo
● Table driven execution
● Data Store
● Tags & tag expressions
● Execution hooks
● Parallel Execution
● Concepts
Suggested Reading
● http://dannorth.net/introducing-bdd/
● http://behaviourdriven.org/
● http://guide.agilealliance.org/guide/bdd.html
● http://dannorth.net/2012/05/31/bdd-is-like-tdd-if/
● http://lizkeogh.com/behaviour-driven-development/
● http://lizkeogh.com/2012/05/30/showcasing-the-language-of-bdd/
● http://benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-
user-stories.html
THANK YOU
For questions or suggestions:
vodqa-hyderabad@thoughtworks.com
getgauge@googlegroups.com
@getgauge
http://getgauge.io

Gauge your BDD Test (vodQA Hyderabad)

  • 1.
    Gauge your BDDTests vodQA Hyderabad 2015 Shivaling Apoorva M Mahendra Kariya
  • 2.
    Agenda ● Discussion aboutBDD (15 mins) ● Hands-on workshop (75 mins) ● Advanced Features Demo (15 mins) ● Q & A (15 mins)
  • 3.
  • 4.
    What is TDD? Test-drivendevelopment (TDD) is a technique for building software that guides software development by writing tests first. - Martin Fowler
  • 5.
    TDD (Contd…) ● Req:Calculation engine to be able to add 2 numbers ● Tests ○ @Test shouldAddPositiveNumbers() { assertEquals(calculator.add(1, 2), 3); } ○ @Test shouldAddNegativeNumbers() { assertEquals(calculator.add(-1, -2), -3); } ○ @Test shouldAddNumbersInWords(){ assertEquals(calculator.add(“one”, “two”), 3); }
  • 6.
    So, BDD then? Peopleare moving towards BDD But what is BDD?
  • 7.
    When asked whatis BDD ● It’s just TDD right? ● That Given-When-Then thing ● Business driven development ● The BA/PO writes the requirements and then the devs write tests
  • 8.
    A collaborative wayto define what behaviour in a system should be tested, by using the same language (natural language) and grammar used to capture the business need. BDD is...
  • 9.
    The Requirement As a[Role] I want [Feature] So that I receive [Value] As an online shopper I want to search for products So that I can make buying decision
  • 10.
    The Test Given [Context] When[Event Occurs] Then [Outcome] Given that I have logged in When I search for a product Then list of related items are displayed
  • 11.
    A Badly WrittenTest Given that I am on the home page When I click on the “login” link And I type text “Mahendra” in the “name” text box And I type “pwd” in the “password” text box And I click the “login” button Then I can see my profile
  • 12.
    A Well WrittenTest Given I land on the homepage When I log into my account with username “Mahendra” and password “pwd” Then I am on the “profile” page
  • 13.
    Another Well WrittenTest ● Open Home Page ● Login with with username “Mahendra” and password “pwd” ● “Profile” page is displayed
  • 14.
    Popular BDD testingframeworks ● Cucumber (https://cucumber.io) ● Jasmine (http://jasmine.github.io) ● JBehave (http://jbehave.org) ● Concordian (http://concordion.org) ● easyb (http://easyb.org)
  • 15.
    In a toolwe want... ● Simplicity because who doesn’t like simple!! ● Maintainability because everyone has been on a long running project and we know it is hell to keep tests working ● Customisability because we all have our own preferences ● Speed because we all have that need for speed
  • 16.
    What if wewant to break away from every form of syntax and write specifications in natural language? Like you’d write an email
  • 17.
  • 18.
    About Gauge ● OpenSource ● Simple Markdown syntax ● Multiple Language Support (Java, C#, Ruby) ● First class parallel execution support ● Extensible and Hackable ● IDE support (IntelliJ, VS, Eclipse) ● First class CI / CD integration support
  • 19.
    Hands - onWorkshop
  • 20.
    Advanced Features Demo ●Table driven execution ● Data Store ● Tags & tag expressions ● Execution hooks ● Parallel Execution ● Concepts
  • 21.
    Suggested Reading ● http://dannorth.net/introducing-bdd/ ●http://behaviourdriven.org/ ● http://guide.agilealliance.org/guide/bdd.html ● http://dannorth.net/2012/05/31/bdd-is-like-tdd-if/ ● http://lizkeogh.com/behaviour-driven-development/ ● http://lizkeogh.com/2012/05/30/showcasing-the-language-of-bdd/ ● http://benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in- user-stories.html
  • 22.
    THANK YOU For questionsor suggestions: vodqa-hyderabad@thoughtworks.com getgauge@googlegroups.com @getgauge http://getgauge.io