BDD

Behaviour Driven Development

Février 2017

  • Solutions webmarketing pour les TPE et artisans
  • 4 pays : France, Espagne, Belgique, Pays-Bas
  • 50 000 sites

Ahmed

  • Développeur Fullstack
  • Scrum Master

Anys

  • Responsable innovation
  • Product Owner

Jukwaa

CMS

Espace Client

Extranet

Pourquoi le BDD ?

Valider le fonctionnement de l'application

Non régression

Documentation vivante

Don't repeat yourself

Mise en place

Environnement technique

  • Symfony
  • Angular
  • NodeJS
  • Protractor
  • CucumberJS

Configuration Protractor

Selenium et environnement

//protractor.conf.js
exports.config = {  
    seleniumAddress: 'http://localhost:4444/wd/hub',  
    specs: ['*.spec.js'],  
    baseURL: 'http://localhost:8080/',  
    framework: 'cucumber',  
};
//test.spec.js
describe('Protractor Test', function() {  
  var addField = element(by.css('[placeholder="add new todo here"]'));  
  var checkedBox = element(by.model('todo.done'));  
  var addButton = element(by.css('[value="add"]'));  

  it('should navigate to the AngularJS homepage', function() {  
    browser.get('https://angularjs.org/'); //overrides baseURL  
  });  
});
#features/test.feature
Feature: Running Cucumber with Protractor
    As a user of Protractor
    I should be able to use Cucumber
    In order to run my E2E tests

    Scenario: Protractor and Cucumber Test
        Given I go to "https://angularjs.org/"
        When I add "Be Awesome" in the task field
        And I click the add button
        Then I should see my new task in the list
module.exports = function() {
  this.Given(/^I go to "([^"]*)"$/, function(site) {
    browser.get(site);
  });

  this.When(/^I add "([^"]*)" in the task field$/, function(task) {
    element(by.model('todoList.todoText')).sendKeys(task);
  });

  this.When(/^I click the add button$/, function() {
    var el = element(by.css('[value="add"]'));
    el.click();
  });

  this.Then(/^I should see my new task in the list$/, function(callback) {
    var todoList = element.all(by.repeater('todo in todoList.todos'));
    expect(todoList.count()).to.eventually.equal(3);
    expect(todoList.get(2).getText()).to.eventually.equal('Do not Be Awesome')
      .and.notify(callback);
  });
};

Protractor

Jasmine

Jasmine Cucumber

Protractor Jasmine Cucumber

Protractor Cucumber

Début 2015

Mi 2015

Fin 2015

Début 2016

A votre

tour !

deck

By anys

deck

  • 687