SlideShare ist ein Scribd-Unternehmen logo
1 von 123
BEHAVIOUR DRIVEN DEVELOPMENT: TDD AND BEYOND THE INFINITE
Duct Tape Religion War
At the beginning…
 
     end;      // CellText := str;    except      // Gabriele non t'ha beccato, Gigi neppure, a chi toccherà?    end; end;
while   ((! found ) && ( pos  < ( fileContent . Length  -   6))) { byteData  =   new   byte[6]; Array . Copy ( fileContent ,  pos ,  byteData ,   0,   6); pos  =  pos  +   6; str_byteData  =  enc . GetString ( byteData ); if   ( str_byteData . Contains ( &quot;s&quot; )) { posE_byteData  =  str_byteData . IndexOf ( &quot;s&quot; ); pos  =  pos  + ( posE_byteData  -   6); Array . Copy ( fileContent ,  pos ,  byteData ,   0,   6); pos  =  pos  +   6; if   ( byteData [0] ==   0x73)   // 's' { if   ( byteData [1] ==   0x74)   // 't' { if   ( byteData [2] ==   0x72)   // 'r' { if   ( byteData [3] ==   0x65)   // 'e' { if   ( byteData [4] ==   0x61)   // 'a' { if   ( byteData [5] ==   0x6D)   // 'm' { found  =   true; break; } else { if   ( byteData [5] ==   0x73) { pos  =  pos  -   1; } } }
function TfrmPreviewTrascr.DBToLinear(DB: Double): Double; begin    //Result := Power(10, DB/20)*1;    Result := Power(10, DB / 100) * 1; { TODO : trovare la relazione corretta }    //LisyLabel4.Caption := Format('%.2f:%.2f', [DB, Result] ); end;
 
 
Kent Beck gave Tdd to programmers!
The Three Laws of TDD
The Three Laws of TDD   1 - You are not allowed to write any production code unless it is to make a failing unit test pass.
The Three Laws of TDD   1 - You are not allowed to write any production code unless it is to make a failing unit test pass. 2 - You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures.
The Three Laws of TDD   1 - You are not allowed to write any production code unless it is to make a failing unit test pass. 2 - You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures. 3 - You are not allowed to write any more production code than is sufficient to pass the one failing unit test.
TDD Cycle
TDD Cycle
TDD Cycle
TDD Cycle
TDD Cycle
TDD Cycle
TDD Cycle
TDD Cycle
TDD Cycle
TDD Cycle
TDD Cycle
Is that the end of our problems?
I’m a programmer, not a tester!
My code it’s difficult to test!
It’s a trivial, doesn’t need a test!
I’ve no time to make automatic tests!
It’s about specifications
Sapir-Whorf hypotesis “ there is a systematic relationship between the grammatical categories of the language a person speaks and how that person both understands the world and behaves in it.”
The Challenge
for ( var  i =  1 ; i <=  100 ; i++){    var  output = i +  &quot;: &quot; ;    if (i %  3  ==  0 ) output +=  &quot;fizz&quot; ;    if (i %  5  ==  0 ) output +=  &quot;buzz&quot; ;   console.log(output); }   48 sec
for ( var  i =  1 ; i <=  100 ; i++){    var  output = i +  &quot;: &quot; ;    if (i %  3  ==  0 ) output +=  &quot;fizz&quot; ;    if (i %  5  ==  0 ) output +=  &quot;buzz&quot; ;   console.log(output); }   But it’s wrong!
puts   ( 1 . .100 ). map   { | n |   '1' * n + &quot;:#{n}  &quot;   }. join . gsub ( /^(1{5})*:/,'Buzz').gsub(/^(1{3})*:/,'Fizz').gsub(/.*:|(z)+/ , '' ) WTF?!?!!
package   biz . scalzo . tdd ; import   junit . framework . Assert ; import   org . junit . Test ; import   biz . scalzo . tdd . Fizzbuzzer ; public class   FizzbuzzTest   { @Test public   void   testForOne (){ Assert . assertEquals ( &quot;1&quot; ,   new   Fizzbuzzer (). count ( 1 )); } } FizzbuzzTest.java
package   biz . scalzo . tdd ; public class   Fizzbuzzer   { public   String   count ( int   i ) { return   null ; } } Fizzbuzzer.java
package   biz . scalzo . tdd ; public class   Fizzbuzzer   { public   String   count ( int   i ) { return   &quot;1&quot; ; } } Fizzbuzzer.java
@Test public   void   testForTwo (){ Assert . assertEquals ( &quot;2&quot; ,   new   Fizzbuzzer (). count ( 2 )); } FizzbuzzTest.java
package   biz . scalzo . tdd ; public class   Fizzbuzzer   { public   String   count ( int   i ) { return   Integer . toString ( i ); } } Fizzbuzzer.java
@Test public   void   testForThree (){ Assert . assertEquals ( &quot;Fizz&quot; ,   new   Fizzbuzzer (). count ( 3 )); } FizzbuzzTest.java
package   biz . scalzo . tdd ; public class   Fizzbuzzer   { public   String   count ( int   i ) { if   ( i   ==   3 ) return   &quot;Fizz&quot; ; return   Integer . toString ( i ); } } Fizzbuzzer.java
@Test public   void   testForFour (){ Assert . assertEquals ( &quot;4&quot; ,   new   Fizzbuzzer (). count ( 4 )); } FizzbuzzTest.java
@Test public   void   testForFive (){ Assert . assertEquals ( &quot;Buzz&quot; ,   new   Fizzbuzzer (). count ( 5 )); } FizzbuzzTest.java
package   biz . scalzo . tdd ; public class   Fizzbuzzer   { public   String   count ( int   i ) { if   ( i   ==   3 ) return   &quot;Fizz&quot; ; if   ( i   ==   5 ) return   &quot;Buzz&quot; ; return   Integer . toString ( i ); } } Fizzbuzzer.java
@Test public   void   testForSix (){ Assert . assertEquals ( &quot;Fizz&quot; ,   new   Fizzbuzzer (). count ( 6 )); } FizzbuzzTest.java
package   biz . scalzo . tdd ; public class   Fizzbuzzer   { public   String   count ( int   i ) { if   ( i   %   3   ==   0 ) return   &quot;Fizz&quot; ; if   ( i   ==   5 ) return   &quot;Buzz&quot; ; return   Integer . toString ( i ); } } Fizzbuzzer.java
@Test public   void   testForSeven (){ Assert . assertEquals ( “7&quot; ,   new   Fizzbuzzer (). count ( 7 )); } FizzbuzzTest.java
@Test public   void   testForEight (){ Assert . assertEquals ( “8&quot; ,   new   Fizzbuzzer (). count ( 8 )); } FizzbuzzTest.java
@Test public   void   testForNine (){ Assert . assertEquals ( “Fizz&quot; ,   new   Fizzbuzzer (). count ( 9 )); } FizzbuzzTest.java
@Test public   void   testForTen (){ Assert . assertEquals ( &quot;Buzz&quot; ,   new   Fizzbuzzer (). count ( 10 )); } FizzbuzzTest.java
package   biz . scalzo . tdd ; public class   Fizzbuzzer   { public   String   count ( int   i ) { if   ( i   %   3   ==   0 ) return   &quot;Fizz&quot; ; if   ( i   %   5   ==   0 ) return   &quot;Buzz&quot; ; return   Integer . toString ( i ); } } Fizzbuzzer.java
package   biz . scalzo . tdd ; public class   Fizzbuzzer   { public   String   count ( int   number ) { if   ( isMultipleOf ( number ,   3 )) return   &quot;Fizz&quot; ; if   ( isMultipleOf ( number ,   5 )) return   &quot;Buzz&quot; ; return   Integer . toString ( number ); } private   boolean   isMultipleOf ( int   number ,   int   multiple ) { return   number   %   multiple   ==   0 ; } } Fizzbuzzer.java
@Test public   void   testForFifteen (){ Assert . assertEquals ( &quot;FizzBuzz&quot; ,   new   Fizzbuzzer (). count ( 15 )); } FizzbuzzTest.java
package   biz . scalzo . tdd ; public class   Fizzbuzzer   { public   String   count ( int   number ) { if   ( isMultipleOf ( number ,   3 ) &&   isMultipleOf ( number ,   5 )) return   &quot;FizzBuzz&quot; ; if   ( isMultipleOf ( number ,   3 )) return   &quot;Fizz&quot; ; if   ( isMultipleOf ( number ,   5 )) return   &quot;Buzz&quot; ; return   Integer . toString ( number ); } private   boolean   isMultipleOf ( int   number ,   int   multiple ) { return   number   %   multiple   ==   0 ; } } Fizzbuzzer.java
package   biz . scalzo . tdd ; public class   Fizzbuzzer   { public   String   count ( int   number ) { String   fizzOrBuzz   =   fizz ( number ) +   buzz ( number ); return   fizzOrBuzz . equals ( &quot;&quot; )   ?   Integer . toString ( number ) :   fizzOrBuzz ; } private   boolean   isMultipleOf ( int   number ,   int   multiple ) { return   number   %   multiple   ==   0 ; } private   String   fizz ( int   number ) { return   isMultipleOf ( number ,   3 )   ?   &quot;Fizz&quot;   :   &quot;&quot; ; } private   String   buzz ( int   number ) { return   isMultipleOf ( number ,   5 )   ?   &quot;Buzz&quot;   :   &quot;&quot; ; } } Fizzbuzzer.java
Result
package   biz . scalzo . tdd ; import   junit . framework . Assert ; import   org . junit . Test ; import   biz . scalzo . tdd . Fizzbuzzer ; public class   FizzbuzzTest   { @Test public   void   testForOne (){ Assert . assertEquals ( &quot;1&quot; ,   new   Fizzbuzzer (). count ( 1 )); } @Test public   void   testForTwo (){ Assert . assertEquals ( &quot;2&quot; ,   new   Fizzbuzzer (). count ( 2 )); } @Test public   void   testForThree (){ Assert . assertEquals ( &quot;Fizz&quot; ,   new   Fizzbuzzer (). count ( 3 )); } @Test public   void   testForFive (){ Assert . assertEquals ( &quot;Buzz&quot; ,   new   Fizzbuzzer (). count ( 5 )); } @Test public   void   testForSix (){ Assert . assertEquals ( &quot;Fizz&quot; ,   new   Fizzbuzzer (). count ( 6 )); } FizzbuzzTest.java
@Test public   void   testForSeven (){ Assert . assertEquals ( &quot;7&quot; ,   new   Fizzbuzzer (). count ( 7 )); } @Test public   void   testForEight (){ Assert . assertEquals ( &quot;8&quot; ,   new   Fizzbuzzer (). count ( 8 )); } @Test public   void   testForNine (){ Assert . assertEquals ( &quot;Fizz&quot; ,   new   Fizzbuzzer (). count ( 9 )); } @Test public   void   testForTen (){ Assert . assertEquals ( &quot;Buzz&quot; ,   new   Fizzbuzzer (). count ( 10 )); } @Test public   void   testForFifteen (){ Assert . assertEquals ( &quot;FizzBuzz&quot; ,   new   Fizzbuzzer (). count ( 15 )); } } FizzbuzzTest.java
 
Bdd Way
Bdd Way Test method names  should  be sentences
package   biz . scalzo . bdd ; import   java . util . ArrayList ; import   java . util . List ; import   org . junit . Test ; import static   org . hamcrest . MatcherAssert . assertThat ; import static   org . hamcrest . Matchers .*; public class   AFizzbuzzer   { @Test public   void   shouldYellOneForOne () { assertThat ( new   Fizzbuzzer (). count ( 1 ),   is ( equalTo ( &quot;1&quot; ))); } } AFizzbuzzer.java
package   biz . scalzo . bdd ; import   java . util . ArrayList ; import   java . util . List ; import   org . junit . Test ; import static   org . hamcrest . MatcherAssert . assertThat ; import static   org . hamcrest . Matchers .*; public class   AFizzbuzzer   { @Test public   void   shouldYellOneForOne () { assertThat ( new   Fizzbuzzer (). count ( 1 ),   is ( equalTo ( &quot;1&quot; ))); } } AFizzbuzzer.java
Bdd Way the class  should  do something
package   biz . scalzo . bdd ; import   java . util . ArrayList ; import   java . util . List ; import   org . junit . Test ; import static   org . hamcrest . MatcherAssert . assertThat ; import static   org . hamcrest . Matchers .*; public class   AFizzbuzzer   { @Test public   void   shouldYellOneForOne () { assertThat ( new   Fizzbuzzer (). count ( 1 ),   is ( equalTo ( &quot;1&quot; ))); } } AFizzbuzzer.java
package   biz . scalzo . bdd ; import   java . util . ArrayList ; import   java . util . List ; import   org . junit . Test ; import static   org . hamcrest . MatcherAssert . assertThat ; import static   org . hamcrest . Matchers .*; public class   AFizzbuzzer   { @Test public   void   shouldYellOneForOne () { assertThat ( new   Fizzbuzzer (). count ( 1 ),   is ( equalTo ( &quot;1&quot; ))); } } AFizzbuzzer.java
@Test public   void   shouldYellTwoForTwo () { assertThat ( new   Fizzbuzzer (). count ( 2 ),   is ( equalTo ( &quot;2&quot; ))); } AFizzbuzzer.java
@Test public   void   shouldYellFizzForMultipleOfThree () { int []   fizzers   = {   3 ,   6 ,   9 ,   12 ,   18   }; for   ( int   fizzer   :   fizzers ) { assertThat ( new   Fizzbuzzer (). count ( fizzer ),   is ( equalTo ( &quot;Fizz&quot; ))); } } AFizzbuzzer.java
@Test public   void   shouldYellBuzzForMultipleOfFive () { int []   buzzers   = {   5 ,   10   }; for   ( int   buzzer   :   buzzers ) { assertThat ( new   Fizzbuzzer (). count ( buzzer ),   is ( equalTo ( &quot;Buzz&quot; ))); } } AFizzbuzzer.java
@Test public   void   shouldYellFizzBuzzForMultipleOfThreeAndFive () { int []   fizzBuzzers   = {   15 ,   30 ,   45 ,   60   }; for   ( int   fizzBuzzer   :   fizzBuzzers   ) { assertThat ( new   Fizzbuzzer (). count ( fizzBuzzer ),   is ( equalTo ( &quot;FizzBuzz&quot; ))); } } AFizzbuzzer.java
@Test public   void   shouldYellTheNumberForNotMultipleOfThreeOrFive () { for   ( int   plainNumber   :   plainNumbers ()) { assertThat ( new   Fizzbuzzer (). count ( plainNumber ),   is ( equalTo ( Integer . toString ( plainNumber )))); } } private   List < Integer >   plainNumbers () { List < Integer >   numbers   =   new   ArrayList < Integer >(); for   ( int   i   =   1 ;   i   <=   100 ;   i ++) numbers . add ( i ); for   ( int   i   =   1 ;   i   <   35 ;   i ++) numbers . remove ( new   Integer ( i   *   3 )); for   ( int   i   =   1 ;   i   <   25 ;   i ++) numbers . remove ( new   Integer ( i   *   5 )); return   numbers ; } AFizzbuzzer.java
 
Fathers of Bdd
The Ruby Way to Bdd
$ :. unshift File . join ( File . dirname ( __FILE__ ), *% w [..   lib ]) require   &quot;fizzbuzzer&quot; describe   &quot;Fizzbuzzer&quot;   do it   &quot;should yell one for one&quot;   do Fizzbuzzer . new . count ( 1 ). should   ==   '1' end end fizzbuzzer_spec.rb
it   &quot;should yell two for two&quot;   do Fizzbuzzer . new . count ( 2 ). should   ==   '2' end fizzbuzzer_spec.rb
it   &quot;should yell Fizz for three&quot;   do Fizzbuzzer . new . count ( 3 ). should   ==   'Fizz' end fizzbuzzer_spec.rb
it   &quot;should yell Fizz for multiple of three&quot;   do [ 3 ,   6 ,   9 ,   12 ]. each   do   | number | Fizzbuzzer . new . count ( number ). should   ==   'Fizz' end end fizzbuzzer_spec.rb
it   &quot;should yell Buzz for multiple of five&quot;   do [ 5 ,   10 ]. each   do   | number | Fizzbuzzer . new . count ( number ). should   ==   'Buzz' end end fizzbuzzer_spec.rb
it   &quot;should yell FizzBuzz for multiple of three and five&quot;   do [ 15 ,   30 ,   45 ]. each   do   | number | Fizzbuzzer . new . count ( number ). should   ==   'FizzBuzz' end end fizzbuzzer_spec.rb
it   &quot;should yell the number itself for non multiple of three or five&quot;   do ( 1 . .100 ). select   { | n |   n   %   3   !=   0   &&   n   %   5   !=   0 }. each   do   | number | Fizzbuzzer . new . count ( number ). should   ==   number . to_s end   end fizzbuzzer_spec.rb
Result
class   Fixnum def   fizzbuzzed ? &quot;FizzBuzz&quot;   if self   %   3   ==   0   &&   self   %   5   ==   0 end def   fizzed ? &quot;Fizz&quot;   if self   %   3   ==   0 end def   buzzed ? &quot;Buzz&quot;   if self   %   5   ==   0 end end class   Fizzbuzzer def   count ( number ) number . fizzbuzzed ? ||   number . fizzed ? ||   number . buzzed ? ||   number . to_s end end fizzbuzzer.rb
describe   &quot;Fizzbuzzer&quot;   do it   &quot;should yell one for one&quot;   do Fizzbuzzer . new . count ( 1 ). should   ==   '1' end it   &quot;should yell two for two&quot;   do Fizzbuzzer . new . count ( 2 ). should   ==   '2' end it   &quot;should yell Fizz for multiple of three&quot;   do [ 3 ,   6 ,   9 ,   12 ]. each   do   | number | Fizzbuzzer . new . count ( number ). should   ==   'Fizz' end end it   &quot;should yell Buzz for multiple of five&quot;   do [ 5 ,   10 ]. each   do   | number | Fizzbuzzer . new . count ( number ). should   ==   'Buzz' end end it   &quot;should yell FizzBuzz for multiple of three and five&quot;   do [ 15 ,   30 ,   45 ]. each   do   | number | Fizzbuzzer . new . count ( number ). should   ==   'FizzBuzz' end end it   &quot;should yell the number itself for non multiple of three or five&quot;   do ( 1 . .100 ). select   { | n |   n   %   3   !=   0   &&   n   %   5   !=   0 }. each   do   | number | Fizzbuzzer . new . count ( number ). should   ==   number . to_s end end end fizzbuzzer_spec.rb
output
output
Stories
As a  [role] I want  [feature] So that  [benefit]   Story
Scenario 1: Title Given  [context]  And  [some more context]... When  [event] Then  [outcome]  And  [another outcome]  Scenario Acceptance Criteria
Cucumber
Cucumber fizzbuzzer.feature fizzbuzzer_steps.rb
Feature :   perfect fizzbuzzing As a inattentive counter I want an automatic Fizzbuzzer So that I can win Fizzbuzz Championsip fizzbuzzer.feature
Scenario :  manage fizz numbers Given a Fizzbuzzer When I ask  for  a multiple of  3 Then Fizzbuzzer yells  'Fizz' fizzbuzzer.feature
require   &quot;fizzbuzzer&quot; Given  &quot;a Fizzbuzzer&quot;   do @fizzbuzzer   =  Fizzbuzzer . new end When  &quot;I ask for a multiple of $m&quot;   do   | m | @result   = [ 1 ,   2 ]. map  { | base | @fizzbuzzer . count ( base * eval ( m ). to_i ) } end Then  &quot;Fizzbuzzer yells '$yell'&quot;   do   | yell | @result . each  do   | result | result . should  ==  yell end end fizzbuzzer_steps.rb
Scenario :  manage buzz numbers Given a Fizzbuzzer When I ask  for  a multiple of  5 Then Fizzbuzzer yells  'Buzz' Scenario :  manage fizzbuzz numbers Given a Fizzbuzzer When I ask  for  a multiple of  3 * 5 Then Fizzbuzzer yells  'FizzBuzz' fizzbuzzer.feature
Scenario :  manage plain numbers Given a Fizzbuzzer When I ask  for  a plain number Then Fizzbuzzer yells the number itself fizzbuzzer.feature
When  &quot;I ask for a plain number&quot;   do @expected   = ( 1 . .100 ). select  { | n |  n  %   3   !=   0   &&  n  %   5   !=   0 } @result   =   @expected . each  do   | number | @fizzbuzzer . count ( number ). to_i end end Then  &quot;Fizzbuzzer yells the number itself&quot;   do @result . should  ==   @expected end fizzbuzzer_steps.rb
Scenario Outline :  manage plain numbers Given a Fizzbuzzer When I ask  for   '<number>' Then Fizzbuzzer yells  '<result>' Examples : |  number  |  result  | |   1   |   1   | |   2   |   2   | |   3   |   Fizz  | |   4   |   4   | |   5   |   Buzz  | |   6   |   Fizz  | fizzbuzzer.feature
When  &quot;I ask for '$m'&quot;   do   | number | @result   =   @fizzbuzzer . count ( number . to_i ) end Then   &quot;Fizzbuzzer yells '$yell'&quot;   do   | yell | @result . each   do   | result | result . should   ==   yell end end fizzbuzzer_steps.rb
neat, isn’t it?
Back to Java
Where it all started
jbehave manage_fizzbuzzer ManageFizzbuzzer.java ManageFizzbuzzerSteps.java
Feature :  perfect fizzbuzzing As a inattentive counter I want an automatic Fizzbuzzer So that I can win Fizzbuzz Championsip Scenario :  manage fizz numbers Given a Fizzbuzzer When I ask  for  a multiple of  3 Then Fizzbuzzer yells  'Fizz' Scenario :  manage buzz numbers Given a Fizzbuzzer When I ask  for  a multiple of  5 Then Fizzbuzzer yells  'Buzz' Scenario :  manage fizzbuzz numbers Given a Fizzbuzzer When I ask  for  a multiple of  15 Then Fizzbuzzer yells  'FizzBuzz' manage_fizzbuzzer
Scenario :  manage plain numbers Given a Fizzbuzzer When I ask  for  a plain number Then Fizzbuzzer yells the number itself Scenario :  manage plain numbers Given a Fizzbuzzer When I ask  for   '[number]' Then Fizzbuzzer yells  '[yell]' Examples : |  number  |  yell  | |   1   |   1   | |   2   |   2   | |   3   |   Fizz  | |   4   |   4   | |   5   |   Buzz  | |   6   |   Fizz  | manage_fizzbuzzer
package  biz . scalzo . jbehave ; import  org . jbehave . scenario . Scenario ; public class  ManageFizzbuzzer  extends  Scenario  { public   ManageFizzbuzzer () { super ( new   ManageFizzbuzzerSteps ()); } } ManageFizzbuzzer.java
import  biz . scalzo . bdd . Fizzbuzzer ; public class  ManageFizzbuzzerSteps  extends  Steps  { private  Fizzbuzzer fizzbuzzer ; private   List < String >  results ; private   List < String >  expected ; private   String  result ; @BeforeScenario public   void   setUp () { expected  =   new   ArrayList < String >(); results  =   new   ArrayList < String >(); } ManageFizzbuzzerSteps.java
@ Given ( &quot;a Fizzbuzzer&quot; ) public   void   startFizzbuzzer () { fizzbuzzer  =   new   Fizzbuzzer (); } @ When ( &quot;I ask for a multiple of $divisor&quot; ) public   void   askForMultipleOf ( int  divisor ) { for   ( int  number  =   1 ;  number  <   3 ; ++ number ) results . add ( fizzbuzzer . count ( number  *  divisor )); } @ Then ( &quot;Fizzbuzzer yells '$yell'&quot; ) public   void   checkYell ( String  yell ) { for   ( String  result  :  results ) { assertThat ( result ,   is ( equalTo ( yell ))); } } ManageFizzbuzzerSteps.java
@ When ( &quot;I ask for a plain number&quot; ) public   void   askForPlainNumbers () { for   ( int  i  =   1 ;  i  <=   100 ;  i ++) if   ( i  %   3   !=   0   &&  i  %   5   !=   0 ) expected . add ( Integer . toString ( i )); for   ( String  number  :  expected ) results . add ( fizzbuzzer . count ( Integer . parseInt ( number ))); } @ Then ( &quot;Fizzbuzzer yells the number itself&quot; ) public   void   yellsNumberItself () { for   ( int  i  =   0 ;  i  <  expected . size ();  i ++) { assertThat ( results . get ( i ),   is ( equalTo ( expected . get ( i )))); } } ManageFizzbuzzerSteps.java
@ When ( &quot;I ask for '[number]'&quot; ) public   void   askFor ( @ Named ( &quot;number&quot; )   int  number ) { result  =  fizzbuzzer . count ( number ); } @ Then ( &quot;Fizzbuzzer yells '[yell]'&quot; ) public   void   checkResult ( @ Named ( &quot;yell&quot; )   String  yell ) { assertThat ( result ,   is ( equalTo ( yell ))); } ManageFizzbuzzerSteps.java
Other Frameworks
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Other Frameworks
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Other Frameworks
Conclusions?
Bdd is about specifications
Homework
http://github.com/coreyhaines/ practice_game_of_life
Feature: Evolving a living cell    In order to create a functioning rules engine    As a programmer of Conway's Game of Life    I can evolve a single living cell      Scenario: Living cell with 0 neighbors dies      Given the following setup        | . | . | . |        | . | x | . |        | . | . | . |      When I evolve the board      Then the center cell should be dead      Scenario: Living cell with 1 neighbor dies      Given the following setup        | . | x | . |        | . | x | . |        | . | . | . |      When I evolve the board      Then the center cell should be dead      Scenario: Living cell with 2 neighbors lives      Given the following setup        | . | x | . |        | . | x | x |        | . | . | . |      When I evolve the board      Then the center cell should be alive      Scenario: Living cell with 3 neighbors lives      Given the following setup        | x | x | x |        | . | x | . |        | . | . | . |      When I evolve the board      Then the center cell should be alive
Start Bdd now!
 
? ? ? ? ? ?

Weitere ähnliche Inhalte

Was ist angesagt?

Grammatical Optimization
Grammatical OptimizationGrammatical Optimization
Grammatical Optimizationadil raja
 
The State of PHPUnit
The State of PHPUnitThe State of PHPUnit
The State of PHPUnitEdorian
 
The State of PHPUnit
The State of PHPUnitThe State of PHPUnit
The State of PHPUnitEdorian
 
Python 3000
Python 3000Python 3000
Python 3000Bob Chao
 
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best PracticesJohannes Hoppe
 
Коварный code type ITGM #9
Коварный code type ITGM #9Коварный code type ITGM #9
Коварный code type ITGM #9Andrey Zakharevich
 
Perl Testing
Perl TestingPerl Testing
Perl Testinglichtkind
 
ITGM #9 - Коварный CodeType, или от segfault'а к работающему коду
ITGM #9 - Коварный CodeType, или от segfault'а к работающему кодуITGM #9 - Коварный CodeType, или от segfault'а к работающему коду
ITGM #9 - Коварный CodeType, или от segfault'а к работающему кодуdelimitry
 
Testes pythonicos com pytest
Testes pythonicos com pytestTestes pythonicos com pytest
Testes pythonicos com pytestviniciusban
 
JBoss Drools
JBoss DroolsJBoss Drools
JBoss DroolsVictor_Cr
 
Voxxed Days Vilnius 2015 - Having fun with Javassist
Voxxed Days Vilnius 2015 - Having fun with JavassistVoxxed Days Vilnius 2015 - Having fun with Javassist
Voxxed Days Vilnius 2015 - Having fun with JavassistAnton Arhipov
 
Антон Нонко, Классические строки в C++
Антон Нонко, Классические строки в C++Антон Нонко, Классические строки в C++
Антон Нонко, Классические строки в C++Sergey Platonov
 
Something about Golang
Something about GolangSomething about Golang
Something about GolangAnton Arhipov
 
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09Ilya Grigorik
 
using python module: doctest
using python module: doctestusing python module: doctest
using python module: doctestmitnk
 
Test-driven development for TYPO3 (T3DD11)
Test-driven development for TYPO3 (T3DD11)Test-driven development for TYPO3 (T3DD11)
Test-driven development for TYPO3 (T3DD11)Oliver Klee
 
Gevent what's the point
Gevent what's the pointGevent what's the point
Gevent what's the pointseanmcq
 

Was ist angesagt? (20)

Grammatical Optimization
Grammatical OptimizationGrammatical Optimization
Grammatical Optimization
 
The State of PHPUnit
The State of PHPUnitThe State of PHPUnit
The State of PHPUnit
 
The State of PHPUnit
The State of PHPUnitThe State of PHPUnit
The State of PHPUnit
 
Python 3000
Python 3000Python 3000
Python 3000
 
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
 
Коварный code type ITGM #9
Коварный code type ITGM #9Коварный code type ITGM #9
Коварный code type ITGM #9
 
Perl Testing
Perl TestingPerl Testing
Perl Testing
 
ITGM #9 - Коварный CodeType, или от segfault'а к работающему коду
ITGM #9 - Коварный CodeType, или от segfault'а к работающему кодуITGM #9 - Коварный CodeType, или от segfault'а к работающему коду
ITGM #9 - Коварный CodeType, или от segfault'а к работающему коду
 
Testes pythonicos com pytest
Testes pythonicos com pytestTestes pythonicos com pytest
Testes pythonicos com pytest
 
JBoss Drools
JBoss DroolsJBoss Drools
JBoss Drools
 
Don't do this
Don't do thisDon't do this
Don't do this
 
Voxxed Days Vilnius 2015 - Having fun with Javassist
Voxxed Days Vilnius 2015 - Having fun with JavassistVoxxed Days Vilnius 2015 - Having fun with Javassist
Voxxed Days Vilnius 2015 - Having fun with Javassist
 
Hidden Gems of Ruby 1.9
Hidden Gems of Ruby 1.9Hidden Gems of Ruby 1.9
Hidden Gems of Ruby 1.9
 
Антон Нонко, Классические строки в C++
Антон Нонко, Классические строки в C++Антон Нонко, Классические строки в C++
Антон Нонко, Классические строки в C++
 
Something about Golang
Something about GolangSomething about Golang
Something about Golang
 
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
 
using python module: doctest
using python module: doctestusing python module: doctest
using python module: doctest
 
Test-driven development for TYPO3 (T3DD11)
Test-driven development for TYPO3 (T3DD11)Test-driven development for TYPO3 (T3DD11)
Test-driven development for TYPO3 (T3DD11)
 
Gevent what's the point
Gevent what's the pointGevent what's the point
Gevent what's the point
 
Spock
SpockSpock
Spock
 

Andere mochten auch

The WHY behind TDD/BDD and the HOW with RSpec
The WHY behind TDD/BDD and the HOW with RSpecThe WHY behind TDD/BDD and the HOW with RSpec
The WHY behind TDD/BDD and the HOW with RSpecBen Mabey
 
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...Zohirul Alam Tiemoon
 
Pair Programming Talk
Pair Programming TalkPair Programming Talk
Pair Programming Talkjlangr
 
Xtreme Programming
Xtreme ProgrammingXtreme Programming
Xtreme ProgrammingNoretSarted
 
ODD: Extending a Specification 1.2
ODD: Extending a Specification 1.2ODD: Extending a Specification 1.2
ODD: Extending a Specification 1.2Jonathan Herring
 
Getting Comfortable with BDD
Getting Comfortable with BDDGetting Comfortable with BDD
Getting Comfortable with BDDAlex Sharp
 
Agile Test Driven Development
Agile Test Driven DevelopmentAgile Test Driven Development
Agile Test Driven DevelopmentViraf Karai
 
Business Value of Agile Testing: Using TDD, CI, CD, & DevOps
Business Value of Agile Testing: Using TDD, CI, CD, & DevOpsBusiness Value of Agile Testing: Using TDD, CI, CD, & DevOps
Business Value of Agile Testing: Using TDD, CI, CD, & DevOpsDavid Rico
 
Test-Driven Development (TDD)
Test-Driven Development (TDD)Test-Driven Development (TDD)
Test-Driven Development (TDD)Brian Rasmussen
 
How to be a great scrum master
How to be a great scrum masterHow to be a great scrum master
How to be a great scrum masterDaniel Shupp
 
Business Value of CI, CD, & DevOpsSec: Scaling to Billion User Systems Using ...
Business Value of CI, CD, & DevOpsSec: Scaling to Billion User Systems Using ...Business Value of CI, CD, & DevOpsSec: Scaling to Billion User Systems Using ...
Business Value of CI, CD, & DevOpsSec: Scaling to Billion User Systems Using ...David Rico
 
BDD in Action: Building Software Right and Building the Right Software
BDD in Action: Building Software Right and Building the Right SoftwareBDD in Action: Building Software Right and Building the Right Software
BDD in Action: Building Software Right and Building the Right SoftwareJohn Ferguson Smart Limited
 
Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Lars Thorup
 
BDD in Action – principles, practices and real-world application
BDD in Action – principles, practices and real-world applicationBDD in Action – principles, practices and real-world application
BDD in Action – principles, practices and real-world applicationJohn Ferguson Smart Limited
 
Agile Methodologies And Extreme Programming
Agile Methodologies And Extreme ProgrammingAgile Methodologies And Extreme Programming
Agile Methodologies And Extreme ProgrammingUtkarsh Khare
 
What is a SCRUM Master
What is a SCRUM MasterWhat is a SCRUM Master
What is a SCRUM MasterJoost Mulders
 

Andere mochten auch (20)

The WHY behind TDD/BDD and the HOW with RSpec
The WHY behind TDD/BDD and the HOW with RSpecThe WHY behind TDD/BDD and the HOW with RSpec
The WHY behind TDD/BDD and the HOW with RSpec
 
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
 
Pair Programming Talk
Pair Programming TalkPair Programming Talk
Pair Programming Talk
 
Xtreme Programming
Xtreme ProgrammingXtreme Programming
Xtreme Programming
 
ODD: Extending a Specification 1.2
ODD: Extending a Specification 1.2ODD: Extending a Specification 1.2
ODD: Extending a Specification 1.2
 
TDD & BDD
TDD & BDDTDD & BDD
TDD & BDD
 
XP In 10 slides
XP In 10 slidesXP In 10 slides
XP In 10 slides
 
Role of scrum master
Role of scrum masterRole of scrum master
Role of scrum master
 
Devops
DevopsDevops
Devops
 
Getting Comfortable with BDD
Getting Comfortable with BDDGetting Comfortable with BDD
Getting Comfortable with BDD
 
Agile Test Driven Development
Agile Test Driven DevelopmentAgile Test Driven Development
Agile Test Driven Development
 
Business Value of Agile Testing: Using TDD, CI, CD, & DevOps
Business Value of Agile Testing: Using TDD, CI, CD, & DevOpsBusiness Value of Agile Testing: Using TDD, CI, CD, & DevOps
Business Value of Agile Testing: Using TDD, CI, CD, & DevOps
 
Test-Driven Development (TDD)
Test-Driven Development (TDD)Test-Driven Development (TDD)
Test-Driven Development (TDD)
 
How to be a great scrum master
How to be a great scrum masterHow to be a great scrum master
How to be a great scrum master
 
Business Value of CI, CD, & DevOpsSec: Scaling to Billion User Systems Using ...
Business Value of CI, CD, & DevOpsSec: Scaling to Billion User Systems Using ...Business Value of CI, CD, & DevOpsSec: Scaling to Billion User Systems Using ...
Business Value of CI, CD, & DevOpsSec: Scaling to Billion User Systems Using ...
 
BDD in Action: Building Software Right and Building the Right Software
BDD in Action: Building Software Right and Building the Right SoftwareBDD in Action: Building Software Right and Building the Right Software
BDD in Action: Building Software Right and Building the Right Software
 
Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)
 
BDD in Action – principles, practices and real-world application
BDD in Action – principles, practices and real-world applicationBDD in Action – principles, practices and real-world application
BDD in Action – principles, practices and real-world application
 
Agile Methodologies And Extreme Programming
Agile Methodologies And Extreme ProgrammingAgile Methodologies And Extreme Programming
Agile Methodologies And Extreme Programming
 
What is a SCRUM Master
What is a SCRUM MasterWhat is a SCRUM Master
What is a SCRUM Master
 

Ähnlich wie Bdd: Tdd and beyond the infinite

Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4Abed Bukhari
 
From typing the test to testing the type
From typing the test to testing the typeFrom typing the test to testing the type
From typing the test to testing the typeWim Godden
 
Python - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave ParkPython - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave Parkpointstechgeeks
 
OrderTest.javapublic class OrderTest {       Get an arra.pdf
OrderTest.javapublic class OrderTest {         Get an arra.pdfOrderTest.javapublic class OrderTest {         Get an arra.pdf
OrderTest.javapublic class OrderTest {       Get an arra.pdfakkhan101
 
So I have this code(StackInAllSocks) and I implemented the method but.pdf
So I have this code(StackInAllSocks) and I implemented the method but.pdfSo I have this code(StackInAllSocks) and I implemented the method but.pdf
So I have this code(StackInAllSocks) and I implemented the method but.pdfaksahnan
 
XpUg Coding Dojo: KataYahtzee in Ocp way
XpUg Coding Dojo: KataYahtzee in Ocp wayXpUg Coding Dojo: KataYahtzee in Ocp way
XpUg Coding Dojo: KataYahtzee in Ocp wayGiordano Scalzo
 
Test-driven Development (TDD)
Test-driven Development (TDD)Test-driven Development (TDD)
Test-driven Development (TDD)Bran van der Meer
 
Effective Java - Still Effective After All These Years
Effective Java - Still Effective After All These YearsEffective Java - Still Effective After All These Years
Effective Java - Still Effective After All These YearsMarakana Inc.
 
Unit8
Unit8Unit8
Unit8md751
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good TestsTomek Kaczanowski
 
GeeCON 2012 Bad Tests, Good Tests
GeeCON 2012 Bad Tests, Good TestsGeeCON 2012 Bad Tests, Good Tests
GeeCON 2012 Bad Tests, Good TestsTomek Kaczanowski
 
Boosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with GroovyBoosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with GroovyJames Williams
 
Javaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 GroovytestingJavaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 GroovytestingAndres Almiray
 
Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Ismar Silveira
 
Confitura 2012 Bad Tests, Good Tests
Confitura 2012 Bad Tests, Good TestsConfitura 2012 Bad Tests, Good Tests
Confitura 2012 Bad Tests, Good TestsTomek Kaczanowski
 

Ähnlich wie Bdd: Tdd and beyond the infinite (20)

Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4
 
From typing the test to testing the type
From typing the test to testing the typeFrom typing the test to testing the type
From typing the test to testing the type
 
Python - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave ParkPython - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave Park
 
Go testdeep
Go testdeepGo testdeep
Go testdeep
 
OrderTest.javapublic class OrderTest {       Get an arra.pdf
OrderTest.javapublic class OrderTest {         Get an arra.pdfOrderTest.javapublic class OrderTest {         Get an arra.pdf
OrderTest.javapublic class OrderTest {       Get an arra.pdf
 
So I have this code(StackInAllSocks) and I implemented the method but.pdf
So I have this code(StackInAllSocks) and I implemented the method but.pdfSo I have this code(StackInAllSocks) and I implemented the method but.pdf
So I have this code(StackInAllSocks) and I implemented the method but.pdf
 
XpUg Coding Dojo: KataYahtzee in Ocp way
XpUg Coding Dojo: KataYahtzee in Ocp wayXpUg Coding Dojo: KataYahtzee in Ocp way
XpUg Coding Dojo: KataYahtzee in Ocp way
 
Test-driven Development (TDD)
Test-driven Development (TDD)Test-driven Development (TDD)
Test-driven Development (TDD)
 
Scala 2 + 2 > 4
Scala 2 + 2 > 4Scala 2 + 2 > 4
Scala 2 + 2 > 4
 
Effective Java - Still Effective After All These Years
Effective Java - Still Effective After All These YearsEffective Java - Still Effective After All These Years
Effective Java - Still Effective After All These Years
 
Unit8
Unit8Unit8
Unit8
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests
 
GeeCON 2012 Bad Tests, Good Tests
GeeCON 2012 Bad Tests, Good TestsGeeCON 2012 Bad Tests, Good Tests
GeeCON 2012 Bad Tests, Good Tests
 
Boosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with GroovyBoosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with Groovy
 
Javaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 GroovytestingJavaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 Groovytesting
 
Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4
 
Google guava
Google guavaGoogle guava
Google guava
 
Confitura 2012 Bad Tests, Good Tests
Confitura 2012 Bad Tests, Good TestsConfitura 2012 Bad Tests, Good Tests
Confitura 2012 Bad Tests, Good Tests
 
Scala introduction
Scala introductionScala introduction
Scala introduction
 
Pooya Khaloo Presentation on IWMC 2015
Pooya Khaloo Presentation on IWMC 2015Pooya Khaloo Presentation on IWMC 2015
Pooya Khaloo Presentation on IWMC 2015
 

Mehr von Giordano Scalzo

The Joy Of Server Side Swift Development
The Joy Of Server Side Swift DevelopmentThe Joy Of Server Side Swift Development
The Joy Of Server Side Swift DevelopmentGiordano Scalzo
 
How to Clone Flappy Bird in Swift
How to Clone Flappy Bird in SwiftHow to Clone Flappy Bird in Swift
How to Clone Flappy Bird in SwiftGiordano Scalzo
 
A swift introduction to Swift
A swift introduction to SwiftA swift introduction to Swift
A swift introduction to SwiftGiordano Scalzo
 
Better Software: introduction to good code
Better Software: introduction to good codeBetter Software: introduction to good code
Better Software: introduction to good codeGiordano Scalzo
 
Tame Accidental Complexity with Ruby and MongoMapper
Tame Accidental Complexity with Ruby and MongoMapperTame Accidental Complexity with Ruby and MongoMapper
Tame Accidental Complexity with Ruby and MongoMapperGiordano Scalzo
 
JavaScript Survival Guide
JavaScript Survival GuideJavaScript Survival Guide
JavaScript Survival GuideGiordano Scalzo
 
Better Software Developers
Better Software DevelopersBetter Software Developers
Better Software DevelopersGiordano Scalzo
 
Agile Iphone Development
Agile Iphone DevelopmentAgile Iphone Development
Agile Iphone DevelopmentGiordano Scalzo
 
10 minutes of me: Giordano Scalzo's Visual Resume
10 minutes of me: Giordano Scalzo's Visual Resume10 minutes of me: Giordano Scalzo's Visual Resume
10 minutes of me: Giordano Scalzo's Visual ResumeGiordano Scalzo
 

Mehr von Giordano Scalzo (13)

The Joy Of Server Side Swift Development
The Joy Of Server Side Swift DevelopmentThe Joy Of Server Side Swift Development
The Joy Of Server Side Swift Development
 
How to Clone Flappy Bird in Swift
How to Clone Flappy Bird in SwiftHow to Clone Flappy Bird in Swift
How to Clone Flappy Bird in Swift
 
A swift introduction to Swift
A swift introduction to SwiftA swift introduction to Swift
A swift introduction to Swift
 
Better Software: introduction to good code
Better Software: introduction to good codeBetter Software: introduction to good code
Better Software: introduction to good code
 
Tame Accidental Complexity with Ruby and MongoMapper
Tame Accidental Complexity with Ruby and MongoMapperTame Accidental Complexity with Ruby and MongoMapper
Tame Accidental Complexity with Ruby and MongoMapper
 
JavaScript Survival Guide
JavaScript Survival GuideJavaScript Survival Guide
JavaScript Survival Guide
 
Code kata
Code kataCode kata
Code kata
 
JavaScript Patterns
JavaScript PatternsJavaScript Patterns
JavaScript Patterns
 
Tdd iPhone For Dummies
Tdd iPhone For DummiesTdd iPhone For Dummies
Tdd iPhone For Dummies
 
Better Software Developers
Better Software DevelopersBetter Software Developers
Better Software Developers
 
Agile Iphone Development
Agile Iphone DevelopmentAgile Iphone Development
Agile Iphone Development
 
10 minutes of me: Giordano Scalzo's Visual Resume
10 minutes of me: Giordano Scalzo's Visual Resume10 minutes of me: Giordano Scalzo's Visual Resume
10 minutes of me: Giordano Scalzo's Visual Resume
 
Scrum in an hour
Scrum in an hourScrum in an hour
Scrum in an hour
 

Kürzlich hochgeladen

Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
The Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central BankingThe Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central BankingSelcen Ozturkcan
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 

Kürzlich hochgeladen (20)

Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central BankingThe Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central Banking
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

Bdd: Tdd and beyond the infinite

  • 1. BEHAVIOUR DRIVEN DEVELOPMENT: TDD AND BEYOND THE INFINITE
  • 4.  
  • 5.     end;     // CellText := str;   except     // Gabriele non t'ha beccato, Gigi neppure, a chi toccherà?   end; end;
  • 6. while ((! found ) && ( pos < ( fileContent . Length - 6))) { byteData = new byte[6]; Array . Copy ( fileContent , pos , byteData , 0, 6); pos = pos + 6; str_byteData = enc . GetString ( byteData ); if ( str_byteData . Contains ( &quot;s&quot; )) { posE_byteData = str_byteData . IndexOf ( &quot;s&quot; ); pos = pos + ( posE_byteData - 6); Array . Copy ( fileContent , pos , byteData , 0, 6); pos = pos + 6; if ( byteData [0] == 0x73) // 's' { if ( byteData [1] == 0x74) // 't' { if ( byteData [2] == 0x72) // 'r' { if ( byteData [3] == 0x65) // 'e' { if ( byteData [4] == 0x61) // 'a' { if ( byteData [5] == 0x6D) // 'm' { found = true; break; } else { if ( byteData [5] == 0x73) { pos = pos - 1; } } }
  • 7. function TfrmPreviewTrascr.DBToLinear(DB: Double): Double; begin   //Result := Power(10, DB/20)*1;   Result := Power(10, DB / 100) * 1; { TODO : trovare la relazione corretta }   //LisyLabel4.Caption := Format('%.2f:%.2f', [DB, Result] ); end;
  • 8.  
  • 9.  
  • 10. Kent Beck gave Tdd to programmers!
  • 11. The Three Laws of TDD
  • 12. The Three Laws of TDD 1 - You are not allowed to write any production code unless it is to make a failing unit test pass.
  • 13. The Three Laws of TDD 1 - You are not allowed to write any production code unless it is to make a failing unit test pass. 2 - You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures.
  • 14. The Three Laws of TDD 1 - You are not allowed to write any production code unless it is to make a failing unit test pass. 2 - You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures. 3 - You are not allowed to write any more production code than is sufficient to pass the one failing unit test.
  • 26. Is that the end of our problems?
  • 27. I’m a programmer, not a tester!
  • 28. My code it’s difficult to test!
  • 29. It’s a trivial, doesn’t need a test!
  • 30. I’ve no time to make automatic tests!
  • 32. Sapir-Whorf hypotesis “ there is a systematic relationship between the grammatical categories of the language a person speaks and how that person both understands the world and behaves in it.”
  • 34. for ( var i = 1 ; i <= 100 ; i++){   var output = i + &quot;: &quot; ;   if (i % 3 == 0 ) output += &quot;fizz&quot; ;   if (i % 5 == 0 ) output += &quot;buzz&quot; ;   console.log(output); } 48 sec
  • 35. for ( var i = 1 ; i <= 100 ; i++){   var output = i + &quot;: &quot; ;   if (i % 3 == 0 ) output += &quot;fizz&quot; ;   if (i % 5 == 0 ) output += &quot;buzz&quot; ;   console.log(output); } But it’s wrong!
  • 36. puts ( 1 . .100 ). map { | n | '1' * n + &quot;:#{n} &quot; }. join . gsub ( /^(1{5})*:/,'Buzz').gsub(/^(1{3})*:/,'Fizz').gsub(/.*:|(z)+/ , '' ) WTF?!?!!
  • 37. package biz . scalzo . tdd ; import junit . framework . Assert ; import org . junit . Test ; import biz . scalzo . tdd . Fizzbuzzer ; public class FizzbuzzTest { @Test public void testForOne (){ Assert . assertEquals ( &quot;1&quot; , new Fizzbuzzer (). count ( 1 )); } } FizzbuzzTest.java
  • 38. package biz . scalzo . tdd ; public class Fizzbuzzer { public String count ( int i ) { return null ; } } Fizzbuzzer.java
  • 39. package biz . scalzo . tdd ; public class Fizzbuzzer { public String count ( int i ) { return &quot;1&quot; ; } } Fizzbuzzer.java
  • 40. @Test public void testForTwo (){ Assert . assertEquals ( &quot;2&quot; , new Fizzbuzzer (). count ( 2 )); } FizzbuzzTest.java
  • 41. package biz . scalzo . tdd ; public class Fizzbuzzer { public String count ( int i ) { return Integer . toString ( i ); } } Fizzbuzzer.java
  • 42. @Test public void testForThree (){ Assert . assertEquals ( &quot;Fizz&quot; , new Fizzbuzzer (). count ( 3 )); } FizzbuzzTest.java
  • 43. package biz . scalzo . tdd ; public class Fizzbuzzer { public String count ( int i ) { if ( i == 3 ) return &quot;Fizz&quot; ; return Integer . toString ( i ); } } Fizzbuzzer.java
  • 44. @Test public void testForFour (){ Assert . assertEquals ( &quot;4&quot; , new Fizzbuzzer (). count ( 4 )); } FizzbuzzTest.java
  • 45. @Test public void testForFive (){ Assert . assertEquals ( &quot;Buzz&quot; , new Fizzbuzzer (). count ( 5 )); } FizzbuzzTest.java
  • 46. package biz . scalzo . tdd ; public class Fizzbuzzer { public String count ( int i ) { if ( i == 3 ) return &quot;Fizz&quot; ; if ( i == 5 ) return &quot;Buzz&quot; ; return Integer . toString ( i ); } } Fizzbuzzer.java
  • 47. @Test public void testForSix (){ Assert . assertEquals ( &quot;Fizz&quot; , new Fizzbuzzer (). count ( 6 )); } FizzbuzzTest.java
  • 48. package biz . scalzo . tdd ; public class Fizzbuzzer { public String count ( int i ) { if ( i % 3 == 0 ) return &quot;Fizz&quot; ; if ( i == 5 ) return &quot;Buzz&quot; ; return Integer . toString ( i ); } } Fizzbuzzer.java
  • 49. @Test public void testForSeven (){ Assert . assertEquals ( “7&quot; , new Fizzbuzzer (). count ( 7 )); } FizzbuzzTest.java
  • 50. @Test public void testForEight (){ Assert . assertEquals ( “8&quot; , new Fizzbuzzer (). count ( 8 )); } FizzbuzzTest.java
  • 51. @Test public void testForNine (){ Assert . assertEquals ( “Fizz&quot; , new Fizzbuzzer (). count ( 9 )); } FizzbuzzTest.java
  • 52. @Test public void testForTen (){ Assert . assertEquals ( &quot;Buzz&quot; , new Fizzbuzzer (). count ( 10 )); } FizzbuzzTest.java
  • 53. package biz . scalzo . tdd ; public class Fizzbuzzer { public String count ( int i ) { if ( i % 3 == 0 ) return &quot;Fizz&quot; ; if ( i % 5 == 0 ) return &quot;Buzz&quot; ; return Integer . toString ( i ); } } Fizzbuzzer.java
  • 54. package biz . scalzo . tdd ; public class Fizzbuzzer { public String count ( int number ) { if ( isMultipleOf ( number , 3 )) return &quot;Fizz&quot; ; if ( isMultipleOf ( number , 5 )) return &quot;Buzz&quot; ; return Integer . toString ( number ); } private boolean isMultipleOf ( int number , int multiple ) { return number % multiple == 0 ; } } Fizzbuzzer.java
  • 55. @Test public void testForFifteen (){ Assert . assertEquals ( &quot;FizzBuzz&quot; , new Fizzbuzzer (). count ( 15 )); } FizzbuzzTest.java
  • 56. package biz . scalzo . tdd ; public class Fizzbuzzer { public String count ( int number ) { if ( isMultipleOf ( number , 3 ) && isMultipleOf ( number , 5 )) return &quot;FizzBuzz&quot; ; if ( isMultipleOf ( number , 3 )) return &quot;Fizz&quot; ; if ( isMultipleOf ( number , 5 )) return &quot;Buzz&quot; ; return Integer . toString ( number ); } private boolean isMultipleOf ( int number , int multiple ) { return number % multiple == 0 ; } } Fizzbuzzer.java
  • 57. package biz . scalzo . tdd ; public class Fizzbuzzer { public String count ( int number ) { String fizzOrBuzz = fizz ( number ) + buzz ( number ); return fizzOrBuzz . equals ( &quot;&quot; ) ? Integer . toString ( number ) : fizzOrBuzz ; } private boolean isMultipleOf ( int number , int multiple ) { return number % multiple == 0 ; } private String fizz ( int number ) { return isMultipleOf ( number , 3 ) ? &quot;Fizz&quot; : &quot;&quot; ; } private String buzz ( int number ) { return isMultipleOf ( number , 5 ) ? &quot;Buzz&quot; : &quot;&quot; ; } } Fizzbuzzer.java
  • 59. package biz . scalzo . tdd ; import junit . framework . Assert ; import org . junit . Test ; import biz . scalzo . tdd . Fizzbuzzer ; public class FizzbuzzTest { @Test public void testForOne (){ Assert . assertEquals ( &quot;1&quot; , new Fizzbuzzer (). count ( 1 )); } @Test public void testForTwo (){ Assert . assertEquals ( &quot;2&quot; , new Fizzbuzzer (). count ( 2 )); } @Test public void testForThree (){ Assert . assertEquals ( &quot;Fizz&quot; , new Fizzbuzzer (). count ( 3 )); } @Test public void testForFive (){ Assert . assertEquals ( &quot;Buzz&quot; , new Fizzbuzzer (). count ( 5 )); } @Test public void testForSix (){ Assert . assertEquals ( &quot;Fizz&quot; , new Fizzbuzzer (). count ( 6 )); } FizzbuzzTest.java
  • 60. @Test public void testForSeven (){ Assert . assertEquals ( &quot;7&quot; , new Fizzbuzzer (). count ( 7 )); } @Test public void testForEight (){ Assert . assertEquals ( &quot;8&quot; , new Fizzbuzzer (). count ( 8 )); } @Test public void testForNine (){ Assert . assertEquals ( &quot;Fizz&quot; , new Fizzbuzzer (). count ( 9 )); } @Test public void testForTen (){ Assert . assertEquals ( &quot;Buzz&quot; , new Fizzbuzzer (). count ( 10 )); } @Test public void testForFifteen (){ Assert . assertEquals ( &quot;FizzBuzz&quot; , new Fizzbuzzer (). count ( 15 )); } } FizzbuzzTest.java
  • 61.  
  • 63. Bdd Way Test method names should be sentences
  • 64. package biz . scalzo . bdd ; import java . util . ArrayList ; import java . util . List ; import org . junit . Test ; import static org . hamcrest . MatcherAssert . assertThat ; import static org . hamcrest . Matchers .*; public class AFizzbuzzer { @Test public void shouldYellOneForOne () { assertThat ( new Fizzbuzzer (). count ( 1 ), is ( equalTo ( &quot;1&quot; ))); } } AFizzbuzzer.java
  • 65. package biz . scalzo . bdd ; import java . util . ArrayList ; import java . util . List ; import org . junit . Test ; import static org . hamcrest . MatcherAssert . assertThat ; import static org . hamcrest . Matchers .*; public class AFizzbuzzer { @Test public void shouldYellOneForOne () { assertThat ( new Fizzbuzzer (). count ( 1 ), is ( equalTo ( &quot;1&quot; ))); } } AFizzbuzzer.java
  • 66. Bdd Way the class should do something
  • 67. package biz . scalzo . bdd ; import java . util . ArrayList ; import java . util . List ; import org . junit . Test ; import static org . hamcrest . MatcherAssert . assertThat ; import static org . hamcrest . Matchers .*; public class AFizzbuzzer { @Test public void shouldYellOneForOne () { assertThat ( new Fizzbuzzer (). count ( 1 ), is ( equalTo ( &quot;1&quot; ))); } } AFizzbuzzer.java
  • 68. package biz . scalzo . bdd ; import java . util . ArrayList ; import java . util . List ; import org . junit . Test ; import static org . hamcrest . MatcherAssert . assertThat ; import static org . hamcrest . Matchers .*; public class AFizzbuzzer { @Test public void shouldYellOneForOne () { assertThat ( new Fizzbuzzer (). count ( 1 ), is ( equalTo ( &quot;1&quot; ))); } } AFizzbuzzer.java
  • 69. @Test public void shouldYellTwoForTwo () { assertThat ( new Fizzbuzzer (). count ( 2 ), is ( equalTo ( &quot;2&quot; ))); } AFizzbuzzer.java
  • 70. @Test public void shouldYellFizzForMultipleOfThree () { int [] fizzers = { 3 , 6 , 9 , 12 , 18 }; for ( int fizzer : fizzers ) { assertThat ( new Fizzbuzzer (). count ( fizzer ), is ( equalTo ( &quot;Fizz&quot; ))); } } AFizzbuzzer.java
  • 71. @Test public void shouldYellBuzzForMultipleOfFive () { int [] buzzers = { 5 , 10 }; for ( int buzzer : buzzers ) { assertThat ( new Fizzbuzzer (). count ( buzzer ), is ( equalTo ( &quot;Buzz&quot; ))); } } AFizzbuzzer.java
  • 72. @Test public void shouldYellFizzBuzzForMultipleOfThreeAndFive () { int [] fizzBuzzers = { 15 , 30 , 45 , 60 }; for ( int fizzBuzzer : fizzBuzzers ) { assertThat ( new Fizzbuzzer (). count ( fizzBuzzer ), is ( equalTo ( &quot;FizzBuzz&quot; ))); } } AFizzbuzzer.java
  • 73. @Test public void shouldYellTheNumberForNotMultipleOfThreeOrFive () { for ( int plainNumber : plainNumbers ()) { assertThat ( new Fizzbuzzer (). count ( plainNumber ), is ( equalTo ( Integer . toString ( plainNumber )))); } } private List < Integer > plainNumbers () { List < Integer > numbers = new ArrayList < Integer >(); for ( int i = 1 ; i <= 100 ; i ++) numbers . add ( i ); for ( int i = 1 ; i < 35 ; i ++) numbers . remove ( new Integer ( i * 3 )); for ( int i = 1 ; i < 25 ; i ++) numbers . remove ( new Integer ( i * 5 )); return numbers ; } AFizzbuzzer.java
  • 74.  
  • 76. The Ruby Way to Bdd
  • 77. $ :. unshift File . join ( File . dirname ( __FILE__ ), *% w [.. lib ]) require &quot;fizzbuzzer&quot; describe &quot;Fizzbuzzer&quot; do it &quot;should yell one for one&quot; do Fizzbuzzer . new . count ( 1 ). should == '1' end end fizzbuzzer_spec.rb
  • 78. it &quot;should yell two for two&quot; do Fizzbuzzer . new . count ( 2 ). should == '2' end fizzbuzzer_spec.rb
  • 79. it &quot;should yell Fizz for three&quot; do Fizzbuzzer . new . count ( 3 ). should == 'Fizz' end fizzbuzzer_spec.rb
  • 80. it &quot;should yell Fizz for multiple of three&quot; do [ 3 , 6 , 9 , 12 ]. each do | number | Fizzbuzzer . new . count ( number ). should == 'Fizz' end end fizzbuzzer_spec.rb
  • 81. it &quot;should yell Buzz for multiple of five&quot; do [ 5 , 10 ]. each do | number | Fizzbuzzer . new . count ( number ). should == 'Buzz' end end fizzbuzzer_spec.rb
  • 82. it &quot;should yell FizzBuzz for multiple of three and five&quot; do [ 15 , 30 , 45 ]. each do | number | Fizzbuzzer . new . count ( number ). should == 'FizzBuzz' end end fizzbuzzer_spec.rb
  • 83. it &quot;should yell the number itself for non multiple of three or five&quot; do ( 1 . .100 ). select { | n | n % 3 != 0 && n % 5 != 0 }. each do | number | Fizzbuzzer . new . count ( number ). should == number . to_s end end fizzbuzzer_spec.rb
  • 85. class Fixnum def fizzbuzzed ? &quot;FizzBuzz&quot; if self % 3 == 0 && self % 5 == 0 end def fizzed ? &quot;Fizz&quot; if self % 3 == 0 end def buzzed ? &quot;Buzz&quot; if self % 5 == 0 end end class Fizzbuzzer def count ( number ) number . fizzbuzzed ? || number . fizzed ? || number . buzzed ? || number . to_s end end fizzbuzzer.rb
  • 86. describe &quot;Fizzbuzzer&quot; do it &quot;should yell one for one&quot; do Fizzbuzzer . new . count ( 1 ). should == '1' end it &quot;should yell two for two&quot; do Fizzbuzzer . new . count ( 2 ). should == '2' end it &quot;should yell Fizz for multiple of three&quot; do [ 3 , 6 , 9 , 12 ]. each do | number | Fizzbuzzer . new . count ( number ). should == 'Fizz' end end it &quot;should yell Buzz for multiple of five&quot; do [ 5 , 10 ]. each do | number | Fizzbuzzer . new . count ( number ). should == 'Buzz' end end it &quot;should yell FizzBuzz for multiple of three and five&quot; do [ 15 , 30 , 45 ]. each do | number | Fizzbuzzer . new . count ( number ). should == 'FizzBuzz' end end it &quot;should yell the number itself for non multiple of three or five&quot; do ( 1 . .100 ). select { | n | n % 3 != 0 && n % 5 != 0 }. each do | number | Fizzbuzzer . new . count ( number ). should == number . to_s end end end fizzbuzzer_spec.rb
  • 90. As a [role] I want [feature] So that [benefit] Story
  • 91. Scenario 1: Title Given [context] And [some more context]... When [event] Then [outcome] And [another outcome] Scenario Acceptance Criteria
  • 94. Feature : perfect fizzbuzzing As a inattentive counter I want an automatic Fizzbuzzer So that I can win Fizzbuzz Championsip fizzbuzzer.feature
  • 95. Scenario : manage fizz numbers Given a Fizzbuzzer When I ask for a multiple of 3 Then Fizzbuzzer yells 'Fizz' fizzbuzzer.feature
  • 96. require &quot;fizzbuzzer&quot; Given &quot;a Fizzbuzzer&quot; do @fizzbuzzer = Fizzbuzzer . new end When &quot;I ask for a multiple of $m&quot; do | m | @result = [ 1 , 2 ]. map { | base | @fizzbuzzer . count ( base * eval ( m ). to_i ) } end Then &quot;Fizzbuzzer yells '$yell'&quot; do | yell | @result . each do | result | result . should == yell end end fizzbuzzer_steps.rb
  • 97. Scenario : manage buzz numbers Given a Fizzbuzzer When I ask for a multiple of 5 Then Fizzbuzzer yells 'Buzz' Scenario : manage fizzbuzz numbers Given a Fizzbuzzer When I ask for a multiple of 3 * 5 Then Fizzbuzzer yells 'FizzBuzz' fizzbuzzer.feature
  • 98. Scenario : manage plain numbers Given a Fizzbuzzer When I ask for a plain number Then Fizzbuzzer yells the number itself fizzbuzzer.feature
  • 99. When &quot;I ask for a plain number&quot; do @expected = ( 1 . .100 ). select { | n | n % 3 != 0 && n % 5 != 0 } @result = @expected . each do | number | @fizzbuzzer . count ( number ). to_i end end Then &quot;Fizzbuzzer yells the number itself&quot; do @result . should == @expected end fizzbuzzer_steps.rb
  • 100. Scenario Outline : manage plain numbers Given a Fizzbuzzer When I ask for '<number>' Then Fizzbuzzer yells '<result>' Examples : | number | result | | 1 | 1 | | 2 | 2 | | 3 | Fizz | | 4 | 4 | | 5 | Buzz | | 6 | Fizz | fizzbuzzer.feature
  • 101. When &quot;I ask for '$m'&quot; do | number | @result = @fizzbuzzer . count ( number . to_i ) end Then &quot;Fizzbuzzer yells '$yell'&quot; do | yell | @result . each do | result | result . should == yell end end fizzbuzzer_steps.rb
  • 104. Where it all started
  • 105. jbehave manage_fizzbuzzer ManageFizzbuzzer.java ManageFizzbuzzerSteps.java
  • 106. Feature : perfect fizzbuzzing As a inattentive counter I want an automatic Fizzbuzzer So that I can win Fizzbuzz Championsip Scenario : manage fizz numbers Given a Fizzbuzzer When I ask for a multiple of 3 Then Fizzbuzzer yells 'Fizz' Scenario : manage buzz numbers Given a Fizzbuzzer When I ask for a multiple of 5 Then Fizzbuzzer yells 'Buzz' Scenario : manage fizzbuzz numbers Given a Fizzbuzzer When I ask for a multiple of 15 Then Fizzbuzzer yells 'FizzBuzz' manage_fizzbuzzer
  • 107. Scenario : manage plain numbers Given a Fizzbuzzer When I ask for a plain number Then Fizzbuzzer yells the number itself Scenario : manage plain numbers Given a Fizzbuzzer When I ask for '[number]' Then Fizzbuzzer yells '[yell]' Examples : | number | yell | | 1 | 1 | | 2 | 2 | | 3 | Fizz | | 4 | 4 | | 5 | Buzz | | 6 | Fizz | manage_fizzbuzzer
  • 108. package biz . scalzo . jbehave ; import org . jbehave . scenario . Scenario ; public class ManageFizzbuzzer extends Scenario { public ManageFizzbuzzer () { super ( new ManageFizzbuzzerSteps ()); } } ManageFizzbuzzer.java
  • 109. import biz . scalzo . bdd . Fizzbuzzer ; public class ManageFizzbuzzerSteps extends Steps { private Fizzbuzzer fizzbuzzer ; private List < String > results ; private List < String > expected ; private String result ; @BeforeScenario public void setUp () { expected = new ArrayList < String >(); results = new ArrayList < String >(); } ManageFizzbuzzerSteps.java
  • 110. @ Given ( &quot;a Fizzbuzzer&quot; ) public void startFizzbuzzer () { fizzbuzzer = new Fizzbuzzer (); } @ When ( &quot;I ask for a multiple of $divisor&quot; ) public void askForMultipleOf ( int divisor ) { for ( int number = 1 ; number < 3 ; ++ number ) results . add ( fizzbuzzer . count ( number * divisor )); } @ Then ( &quot;Fizzbuzzer yells '$yell'&quot; ) public void checkYell ( String yell ) { for ( String result : results ) { assertThat ( result , is ( equalTo ( yell ))); } } ManageFizzbuzzerSteps.java
  • 111. @ When ( &quot;I ask for a plain number&quot; ) public void askForPlainNumbers () { for ( int i = 1 ; i <= 100 ; i ++) if ( i % 3 != 0 && i % 5 != 0 ) expected . add ( Integer . toString ( i )); for ( String number : expected ) results . add ( fizzbuzzer . count ( Integer . parseInt ( number ))); } @ Then ( &quot;Fizzbuzzer yells the number itself&quot; ) public void yellsNumberItself () { for ( int i = 0 ; i < expected . size (); i ++) { assertThat ( results . get ( i ), is ( equalTo ( expected . get ( i )))); } } ManageFizzbuzzerSteps.java
  • 112. @ When ( &quot;I ask for '[number]'&quot; ) public void askFor ( @ Named ( &quot;number&quot; ) int number ) { result = fizzbuzzer . count ( number ); } @ Then ( &quot;Fizzbuzzer yells '[yell]'&quot; ) public void checkResult ( @ Named ( &quot;yell&quot; ) String yell ) { assertThat ( result , is ( equalTo ( yell ))); } ManageFizzbuzzerSteps.java
  • 114.
  • 115.
  • 117. Bdd is about specifications
  • 120. Feature: Evolving a living cell    In order to create a functioning rules engine    As a programmer of Conway's Game of Life    I can evolve a single living cell      Scenario: Living cell with 0 neighbors dies      Given the following setup        | . | . | . |        | . | x | . |        | . | . | . |      When I evolve the board      Then the center cell should be dead      Scenario: Living cell with 1 neighbor dies      Given the following setup        | . | x | . |        | . | x | . |        | . | . | . |      When I evolve the board      Then the center cell should be dead      Scenario: Living cell with 2 neighbors lives      Given the following setup        | . | x | . |        | . | x | x |        | . | . | . |      When I evolve the board      Then the center cell should be alive      Scenario: Living cell with 3 neighbors lives      Given the following setup        | x | x | x |        | . | x | . |        | . | . | . |      When I evolve the board      Then the center cell should be alive
  • 122.  
  • 123. ? ? ? ? ? ?

Hinweis der Redaktion

  1. si usa un semplice template per testare le classi. ogni classe ha un suo test case e aiuta a rimanere focalizzati
  2. la classe ‘dovrebbe’ non ‘deve’ fare qualcosa in modo da indicare un comportamento possibile: se c’è un errore potrebbe essere un bug oppure potrebbe essere che quel comportamento non è più di quella classe
  3. conversazione. rspec per sviluppatori. vecchio sogno che gli stakeholders possano scrivere direttamente le specifiche. si può avere un linguaggio di più alto livello
  4. conversazione