Oxente, ramo falar de BDD
 macho, depois rebola no
  mato esse codigo réi!
           Não cuideis que vim trazer a paz à terra;
           não vim trazer paz, mas pexeira;
           http://www.bibliaonline.com.br/acf/mt/10
Traditional Software Life Cycle


                   Software Life Cycle

     Development     Maintenance




  First Deploy - Transition
Traditional Iterations
Process Disciplines             Inception Elaboration            Construction          Transition

           Business Modeling
                Requirements
            Analysis & Design
               Implementation
                         Test
                  Deployment
                                Preliminary     Iter.   Iter.   Iter.    Iter. Iter.   Iter.    Iter.
                                Iteration(s)‫‏‬    #1     #2      #n      #n+1 #n+2      #m      #m+1

                                                            Iterations



   Business Requirements Analysis    Design Implementation Test Deployment
Too Late Feedback
Process Disciplines             Inception Elaboration            Construction          Transition

           Business Modeling
                Requirements
            Analysis & Design
               Implementation
                         Test
                  Deployment
                                Preliminary     Iter.   Iter.   Iter.    Iter. Iter.   Iter.    Iter.
                                Iteration(s)‫‏‬    #1     #2      #n      #n+1 #n+2      #m      #m+1

                                                            Iterations



   Business Requirements Analysis    Design Implementation Test Deployment

       failure when changes happen or feature misunderstood
Laggards Tests
Process Disciplines             Inception Elaboration            Construction          Transition

           Business Modeling
                Requirements
            Analysis & Design
               Implementation
                         Test
                  Deployment
                                Preliminary     Iter.   Iter.   Iter.    Iter. Iter.   Iter.    Iter.
                                Iteration(s)‫‏‬    #1     #2      #n      #n+1 #n+2      #m      #m+1

                                                            Iterations



   Business Requirements Analysis    Design Implementation Test Deployment


                 Fragile coverage and poor code
                 with low Cohesion and high Coupling
Migrating to Agile Iteration

 Process Disciplines            Inception Elaboration            Construction          Transition

           Business Modeling
                Requirements
            Analysis & Design
              Implementation
                        Test
                 Deployment
                                Preliminary     Iter.   Iter.   Iter.    Iter. Iter.   Iter.    Iter.
                                Iteration(s)‫‏‬   #1      #2      #n      #n+1 #n+2      #m      #m+1

                                                            Iterations
Not Enough Time

 Process Disciplines            Inception Elaboration            Construction          Transition

           Business Modeling
                Requirements
            Analysis & Design
              Implementation
                        Test
                 Deployment
                                Preliminary     Iter.   Iter.   Iter.    Iter. Iter.   Iter.    Iter.
                                Iteration(s)‫‏‬   #1      #2      #n      #n+1 #n+2      #m      #m+1

                                                            Iterations



                  Tests are traditionally discarded
                  when not enough time
Test First Practice

 Process Disciplines            Inception Elaboration            Construction          Transition

                       Test
           Business Modeling
                Requirements
            Analysis & Design
              Implementation
                 Deployment
                                Preliminary     Iter.   Iter.   Iter.    Iter. Iter.   Iter.    Iter.
                                Iteration(s)‫‏‬   #1      #2      #n      #n+1 #n+2      #m      #m+1

                                                            Iterations



                Test First modifies the traditional
                approach to modeling and analysis
Test Driven Development



      "Test-driven development is a way of
      managing fear during programming."

                         Kent Beck - Test Driven
                         Development by Example
Daily Development
  Standup Meeting          Pair Up


   TDD Cycle

                    Test



             Code          Refactoring




        Integrate
Red Bar Patterns
One Step Test
Starter Test       Testing Bar Patterns
Explanation Test       Child Test
Learning Test          Mock Object
Another Test           Self Shunt
Regression Test        Crash Test Dummy
Break                  Broken Test
Do Over                Clean Check-Inc

     Test Double
          Dummy     Green Bar Patterns
          Fake       Fake It (Till you make it)‫‏‬
          Stubs      Triangulate
          Spies      Obvious Implementation
          Mocks      One to Many
The Three A's in TDD


        Arrange (create an object)‫‏‬
        Act     (executing a method)‫‏‬
        Assert (verifying a result)‫‏‬


               Refactoring Workbook, Bill Wake
Arrange




var object = Object.create({test:10});
Act




   var object = Object.create({test:10});
var verified = object.trying("test");
Assert




   var object = Object.create({test:10});
var verified = object.trying("test");

ok( verified == 10 );
3A



var object = Object.create({test:10});
var verified = object.trying("test");
ok( verified == 10 );
XUnit


test("Trying contents of a property
without throwing exception", function()
{
  var object = Object.create({test:10})
  ok( object.trying("test") == 10, "Cool" );
});
What You Are Doing



describe('jsonform',function(){




});
Establish The Context


describe('jsonform',function(){

      context('Populate form with json',function(){

      }

});
Specify The Behavior

describe('jsonform',function(){

      context('Populate form',function(){
        it('Json with object nested',function(){

          }
      }

});
Should
describe('jsonform',function(){
    context('Populate form',function(){
      it('Json with object nested',function(){
          jQuery('#jsonform').jsonform(object,
              function(json) {
                 expect(jQuery(query).val().toString())
                .toEqual("1.02.0002");
          });
      }
    }
});
Behaviour




BDD provides a “ubiquitous language” for analysis
                   Dan North
      http://dannorth.net/introducing-bdd/
Acceptance




   As a
  I want
  so that
Criteria




Given some initial context (the givens),
       When an event occurs,
    Then ensure some outcomes.
ATDD
feature('Using jQuery plugin to populate form', function() {
 summary(
    'In order to submit my form',
    'As a user',
    'I want populate a form with json'
 );
 scenario('The is stopped with the engine off', function() {
    var object;
    given('json object', function() {

         });
        and('form html', function() {

        });
        when('I press the start button', function() {

        });
        then('The expected ', function() {
          expect(expected).toEqual("expected");
        });
  });
});
ATDD
feature('Using jQuery plugin to populate form', function() {
  summary(
      'In order to submit my form',
      'As a user',
      'I want populate a form with json'
  );
  scenario('The is stopped with the engine off', function() {
      var object;
      given('json object', function() {
        object = {
            nested: {id: 2, name: "Teste"},
            array_nested: [
               {nested: {id: 3, name: "Teste"} }
            ],
            description: "Teste",
            value: "125,67",
            date: "12/03/1999"
          };
        });
      and('form html', function() {
        var template = "<form action='#' id='jsonform'> 
        ...
        </form>";
        jQuery(template).appendTo("body");
      });
      when('I press the start button', function() {
        jQuery('#jsonform').jsonform(object);
      });
      then('The car should start up', function() {
        expect(jQuery(query).val().toString()).toEqual("Teste");
      });
  });
});
Daily Development
  Standup Meeting                      Pair Up


   BDD/TDD Cycle       Acceptance                 Model
                          Test                   Storming


                           Test

                    Code      Refactoring
     Refactoring                             Code



        Integrate
BDD




TDD + DDD (+ATDD)
Transition Frontier Broken


                                                 Software Life Cycle

                  Development                           Maintenance
                  Desenvolvimento                       Manutenção

            Test              Test              Test
        Modeling          Modeling          Modeling
   Requirements      Requirements      Requirements
Analysis & Design Analysis & Design Analysis & Design
 Implementation    Implementation    Implementation
    Deployment        Deployment        Deployment




                             Transition frontier no longer makes sense
Oxente BDD

Oxente BDD

  • 1.
    Oxente, ramo falarde BDD macho, depois rebola no mato esse codigo réi! Não cuideis que vim trazer a paz à terra; não vim trazer paz, mas pexeira; http://www.bibliaonline.com.br/acf/mt/10
  • 2.
    Traditional Software LifeCycle Software Life Cycle Development Maintenance First Deploy - Transition
  • 3.
    Traditional Iterations Process Disciplines Inception Elaboration Construction Transition Business Modeling Requirements Analysis & Design Implementation Test Deployment Preliminary Iter. Iter. Iter. Iter. Iter. Iter. Iter. Iteration(s)‫‏‬ #1 #2 #n #n+1 #n+2 #m #m+1 Iterations Business Requirements Analysis Design Implementation Test Deployment
  • 4.
    Too Late Feedback ProcessDisciplines Inception Elaboration Construction Transition Business Modeling Requirements Analysis & Design Implementation Test Deployment Preliminary Iter. Iter. Iter. Iter. Iter. Iter. Iter. Iteration(s)‫‏‬ #1 #2 #n #n+1 #n+2 #m #m+1 Iterations Business Requirements Analysis Design Implementation Test Deployment failure when changes happen or feature misunderstood
  • 5.
    Laggards Tests Process Disciplines Inception Elaboration Construction Transition Business Modeling Requirements Analysis & Design Implementation Test Deployment Preliminary Iter. Iter. Iter. Iter. Iter. Iter. Iter. Iteration(s)‫‏‬ #1 #2 #n #n+1 #n+2 #m #m+1 Iterations Business Requirements Analysis Design Implementation Test Deployment Fragile coverage and poor code with low Cohesion and high Coupling
  • 6.
    Migrating to AgileIteration Process Disciplines Inception Elaboration Construction Transition Business Modeling Requirements Analysis & Design Implementation Test Deployment Preliminary Iter. Iter. Iter. Iter. Iter. Iter. Iter. Iteration(s)‫‏‬ #1 #2 #n #n+1 #n+2 #m #m+1 Iterations
  • 7.
    Not Enough Time Process Disciplines Inception Elaboration Construction Transition Business Modeling Requirements Analysis & Design Implementation Test Deployment Preliminary Iter. Iter. Iter. Iter. Iter. Iter. Iter. Iteration(s)‫‏‬ #1 #2 #n #n+1 #n+2 #m #m+1 Iterations Tests are traditionally discarded when not enough time
  • 8.
    Test First Practice Process Disciplines Inception Elaboration Construction Transition Test Business Modeling Requirements Analysis & Design Implementation Deployment Preliminary Iter. Iter. Iter. Iter. Iter. Iter. Iter. Iteration(s)‫‏‬ #1 #2 #n #n+1 #n+2 #m #m+1 Iterations Test First modifies the traditional approach to modeling and analysis
  • 9.
    Test Driven Development "Test-driven development is a way of managing fear during programming." Kent Beck - Test Driven Development by Example
  • 10.
    Daily Development Standup Meeting Pair Up TDD Cycle Test Code Refactoring Integrate
  • 11.
    Red Bar Patterns OneStep Test Starter Test Testing Bar Patterns Explanation Test Child Test Learning Test Mock Object Another Test Self Shunt Regression Test Crash Test Dummy Break Broken Test Do Over Clean Check-Inc Test Double Dummy Green Bar Patterns Fake Fake It (Till you make it)‫‏‬ Stubs Triangulate Spies Obvious Implementation Mocks One to Many
  • 12.
    The Three A'sin TDD Arrange (create an object)‫‏‬ Act (executing a method)‫‏‬ Assert (verifying a result)‫‏‬ Refactoring Workbook, Bill Wake
  • 13.
    Arrange var object =Object.create({test:10});
  • 14.
    Act var object = Object.create({test:10}); var verified = object.trying("test");
  • 15.
    Assert var object = Object.create({test:10}); var verified = object.trying("test"); ok( verified == 10 );
  • 16.
    3A var object =Object.create({test:10}); var verified = object.trying("test"); ok( verified == 10 );
  • 17.
    XUnit test("Trying contents ofa property without throwing exception", function() { var object = Object.create({test:10}) ok( object.trying("test") == 10, "Cool" ); });
  • 18.
    What You AreDoing describe('jsonform',function(){ });
  • 19.
    Establish The Context describe('jsonform',function(){ context('Populate form with json',function(){ } });
  • 20.
    Specify The Behavior describe('jsonform',function(){ context('Populate form',function(){ it('Json with object nested',function(){ } } });
  • 21.
    Should describe('jsonform',function(){ context('Populate form',function(){ it('Json with object nested',function(){ jQuery('#jsonform').jsonform(object, function(json) { expect(jQuery(query).val().toString()) .toEqual("1.02.0002"); }); } } });
  • 22.
    Behaviour BDD provides a“ubiquitous language” for analysis Dan North http://dannorth.net/introducing-bdd/
  • 23.
    Acceptance As a I want so that
  • 24.
    Criteria Given some initialcontext (the givens), When an event occurs, Then ensure some outcomes.
  • 25.
    ATDD feature('Using jQuery pluginto populate form', function() { summary( 'In order to submit my form', 'As a user', 'I want populate a form with json' ); scenario('The is stopped with the engine off', function() { var object; given('json object', function() { }); and('form html', function() { }); when('I press the start button', function() { }); then('The expected ', function() { expect(expected).toEqual("expected"); }); }); });
  • 26.
    ATDD feature('Using jQuery pluginto populate form', function() { summary( 'In order to submit my form', 'As a user', 'I want populate a form with json' ); scenario('The is stopped with the engine off', function() { var object; given('json object', function() { object = { nested: {id: 2, name: "Teste"}, array_nested: [ {nested: {id: 3, name: "Teste"} } ], description: "Teste", value: "125,67", date: "12/03/1999" }; }); and('form html', function() { var template = "<form action='#' id='jsonform'> ... </form>"; jQuery(template).appendTo("body"); }); when('I press the start button', function() { jQuery('#jsonform').jsonform(object); }); then('The car should start up', function() { expect(jQuery(query).val().toString()).toEqual("Teste"); }); }); });
  • 27.
    Daily Development Standup Meeting Pair Up BDD/TDD Cycle Acceptance Model Test Storming Test Code Refactoring Refactoring Code Integrate
  • 28.
  • 29.
    Transition Frontier Broken Software Life Cycle Development Maintenance Desenvolvimento Manutenção Test Test Test Modeling Modeling Modeling Requirements Requirements Requirements Analysis & Design Analysis & Design Analysis & Design Implementation Implementation Implementation Deployment Deployment Deployment Transition frontier no longer makes sense