Hire monkey

Vs

BDD*

* Behavior-driven development

Created by Fabien Garcia

How to be sure that your web app is working?

You can trust developpers

You test it!

  1. You open a browser
  2. Visit the url of your application
  3. Fill in a form
  4. Check if the page should have the right content

And you do it for every single change, and you check for every single page, for every case

Advantages

  • You will become really good using your application

Drawbacks

  • Time consuming
  • Do not add value to the product
  • Do not let you focus on the user experience
  • Stupid task

A better solution?

Why not hire a monkey?

Advantages

  • You pay him with banana
  • It will do any stupid task
  • It could repeat action as long as you give bananas

Drawbacks

  • It's a monkey ;-)
  • Training time
  • It could be loud
  • The office is not suitable

So let's find a better solution...

BDD*

* Behavior-driven development

Cucumber

It's a hight level framework testing

See more here

Let's see


# language: en
Feature: Addition
  In order to avoid silly mistakes
  As a math idiot 
  I want to be told the sum of two numbers

  Scenario Outline: Add two numbers
    Given I have entered <input_1> into the calculator
    And I have entered <input_2> into the calculator
    When I press <button>
    Then the result should be <output> on the screen
  Examples:
    | input_1 | input_2 | button | output |
    | 20      | 30      | add    | 50     |
    | 2       | 5       | add    | 7      |
    | 0       | 40      | add    | 40     |

Advantages

  • The syntax is really similar to a real User-story
  • High level testing

Drawbacks

  • Need to learne the syntax
  • Syntax has no link with ruby

Rspec with sugar*

* Capybara, Selenium-webdriver, Factory_girl_rails, ...

Framework for testing developer friendly and easy to read.

Let's see

 
  describe "Search /blog" do
    it "should be able to search into the blog database" do
      post = FactoryGirl.create(:post)
      post2 = FactoryGirl.create(:post, title: 'other staff' )
      visit home_path
      fill_in 'search', :with => 'article top'
      click_on 'Search'
      page.should have_content("article top")
    end
  end
end
          

Advantages

  • Really flexible allow hight level testing and unit test
  • With the sugar test case are easy to read for non developer
  • Close to the ruby
  • Could be integrate with Selenium

Drawbacks

  • Need to understand Ruby
We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true

Robert Wilensky

Question?

THE END

BY Fabien Garcia