The testing, The monkey & the 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


  • You will become really good using your application


  • 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?


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


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

So let's find a better solution...

Let's hire a robot!


  • You do not pay him
  • It will do any stupid task
  • It can test every part of your application, not just the interface
  • It could repeat action as long as you want
  • it's a computer


  • Not cute like a monkey
  • Need to program this robot

How we programm this robot?


* Behavior-driven development

Let see the frameworks to program our robot


It's a hight level framework testing

See more here

Let's see

Feature: Search
  In order to learn more
  As an information seeker
  I want to find more information

  Scenario: Find what I'm looking for
    Given I am on the search page
    And I have posts titled article top, other staff
    When I search for "article top"
    Then I should see
      article top

Under the hood!

You also need to define specific words

Given 'I am on the search page' do
  @browser.goto '/search'

When /I search for "(.*)"/ do |query|
  @browser.text_field(:name, 'q').set(query)
  @browser.button(:name, 'btnG').click

Then /I should see/ do |text\
  @browser.text.should =~ /#{text}/m


  • The syntax is really similar to a real User-story
  • Framework force to write straightforward user stories
  • High level testing


  • Need to learn the syntax
  • Syntax has no link with ruby
  • You need extra work to define specific task

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")


  • 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
  • When it's written nothing to add
  • Could be integrate with Selenium


  • Need to understand Ruby

How we know when test are passing?

You can trust your developpers

You use a building tool

It will give you a nice interface to build your project and see test result

(without knowing anything about development)


See more

One of the most famous, using Java to run on a server

  • Really powerful :-)
  • Any language
  • Really complexe to setup :-(


See more

Really powerfull solution for open source project

  • Really powerfull
  • Any language
  • Really easy to setup for opensource project
  • Really expensif/complex to setup for private project


See more

Build tool made with ruby on rails

  • Really simple to use
  • Simple to setup and install
  • Works for any project
  • Any language
  • Too simple


Choose one but you have to test ! *

* except maybe for a small project 1 or 2 days long and with a really short life span and witch will never change !

To go further

Smart quotation

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



BY Fabien Garcia