30
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

Oxente BDD

Embed Size (px)

DESCRIPTION

Palestra no Marebase2011 com titulo: "Oxente, ramo falar de BDD macho, depois rebola no mato esse codigo réi!"

Citation preview

Page 1: Oxente BDD

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

Page 2: Oxente BDD

Traditional Software Life Cycle

Software Life Cycle

DevelopmentDevelopment MaintenanceMaintenance

First Deploy - Transition

Page 3: Oxente BDD

Traditional Iterations

Business Modeling

Implementation

Test

Analysis & Design

Preliminary Iteration(s)‏

Iter.#1

Process Disciplines

Iterations

Iter.#2

Iter.#n

Iter.#n+1

Iter.#n+2

Iter.#m

Iter.#m+1

Deployment

Requirements

Elaboration TransitionInception Construction

BusinessBusiness RequirementsRequirements AnalysisAnalysis DesignDesign ImplementationImplementation TestTest DeploymentDeployment

Page 4: Oxente BDD

Too Late Feedback

Business Modeling

Implementation

Test

Analysis & Design

Preliminary Iteration(s)‏

Iter.#1

Process Disciplines

Iterations

Iter.#2

Iter.#n

Iter.#n+1

Iter.#n+2

Iter.#m

Iter.#m+1

Deployment

Requirements

Elaboration TransitionInception Construction

BusinessBusiness RequirementsRequirements AnalysisAnalysis DesignDesign ImplementationImplementation TestTest DeploymentDeployment

failure when changes happen or feature misunderstood

Page 5: Oxente BDD

Laggards Tests

Business Modeling

Implementation

Test

Analysis & Design

Preliminary Iteration(s)‏

Iter.#1

Process Disciplines

Iterations

Iter.#2

Iter.#n

Iter.#n+1

Iter.#n+2

Iter.#m

Iter.#m+1

Deployment

Requirements

Elaboration TransitionInception Construction

BusinessBusiness RequirementsRequirements AnalysisAnalysis DesignDesign ImplementationImplementation TestTest DeploymentDeployment

Fragile coverage and poor code with low Cohesion and high Coupling

Page 6: Oxente BDD

Migrating to Agile Iteration

Business Modeling

Implementation

Test

Analysis & Design

Preliminary Iteration(s)‏

Iter.#1

Process Disciplines

Iterations

Iter.#2

Iter.#n

Iter.#n+1

Iter.#n+2

Iter.#m

Iter.#m+1

Deployment

Requirements

Elaboration TransitionInception Construction

Page 7: Oxente BDD

Not Enough Time

Business Modeling

Implementation

Test

Analysis & Design

Preliminary Iteration(s)‏

Iter.#1

Process Disciplines

Iterations

Iter.#2

Iter.#n

Iter.#n+1

Iter.#n+2

Iter.#m

Iter.#m+1

Deployment

Requirements

Elaboration TransitionInception Construction

Tests are traditionally discarded when not enough time

Page 8: Oxente BDD

Test First Practice

Business Modeling

Implementation

Test

Analysis & Design

Preliminary Iteration(s)‏

Iter.#1

Process Disciplines

Iterations

Iter.#2

Iter.#n

Iter.#n+1

Iter.#n+2

Iter.#m

Iter.#m+1

Deployment

Requirements

Elaboration TransitionInception Construction

Test First modifies the traditional approach to modeling and analysis

Page 9: Oxente BDD

Test Driven Development

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

Kent Beck - Test Driven Development by Example

Page 10: Oxente BDD

Daily Development

Standup Meeting

Test

Code Refactoring

Integrate

Pair Up

TDD Cycle

Page 11: Oxente BDD

Red Bar PatternsOne Step TestStarter TestExplanation TestLearning TestAnother TestRegression TestBreakDo Over

Fake It (Till you make it) ‏TriangulateObvious ImplementationOne to Many

Green Bar Patterns

Testing Bar PatternsChild TestMock ObjectSelf ShuntCrash Test DummyBroken TestClean Check-Inc

Test DoubleDummyFakeStubsSpiesMocks

Page 12: Oxente BDD

The Three A's in TDD

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

Refactoring Workbook, Bill Wake

Page 13: Oxente BDD

Arrange

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

Page 14: Oxente BDD

Act

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

Page 15: Oxente BDD

Assert

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

ok( verified == 10 );

Page 16: Oxente BDD

3A

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

Page 17: Oxente BDD

XUnit

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

Page 18: Oxente BDD

What You Are Doing

describe('jsonform',function(){

});

Page 19: Oxente BDD

Establish The Context

describe('jsonform',function(){

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

});

Page 20: Oxente BDD

Specify The Behavior

describe('jsonform',function(){

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

});

Page 21: Oxente BDD

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

Page 22: Oxente BDD

Behaviour

BDD provides a “ubiquitous language” for analysisDan North

http://dannorth.net/introducing-bdd/

Page 23: Oxente BDD

Acceptance

As aI wantso that

Page 24: Oxente BDD

Criteria

Given some initial context (the givens),When an event occurs,

Then ensure some outcomes.

Page 25: Oxente BDD

ATDDfeature('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"); }); });});

Page 26: Oxente BDD

ATDDfeature('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"); }); });});

Page 27: Oxente BDD

Daily Development

Standup Meeting

Test

Code Refactoring

Integrate

Pair Up

BDD/TDD Cycle AcceptanceTest

CodeRefactoring

Model Storming

Page 28: Oxente BDD

BDD

TDD + DDD (+ATDD)

Page 29: Oxente BDD

Transition Frontier Broken

Software Life Cycle

DevelopmentDevelopmentDesenvolvimentoDesenvolvimento

MaintenanceMaintenanceManutençãoManutenção

Transition frontier no longer makes sense

Modeling

Implementation

Test

Analysis & Design

Deployment

RequirementsModeling

Implementation

Test

Analysis & Design

Deployment

RequirementsModeling

Implementation

Test

Analysis & Design

Deployment

Requirements

Page 30: Oxente BDD