0% found this document useful (0 votes)
58 views

4 - Test Driven Development

This document provides an introduction to test-driven development (TDD). It discusses how TDD involves first writing tests that fail before writing new code to pass the tests. TDD encourages iterative development and finding defects early. The document then introduces the bowling game kata as a learning exercise to practice TDD techniques through repetition. Developers are instructed to first master the bowling game kata before applying TDD to a mini-project by developing a component with tests written using a framework like JUnit.

Uploaded by

Fabian Vargas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

4 - Test Driven Development

This document provides an introduction to test-driven development (TDD). It discusses how TDD involves first writing tests that fail before writing new code to pass the tests. TDD encourages iterative development and finding defects early. The document then introduces the bowling game kata as a learning exercise to practice TDD techniques through repetition. Developers are instructed to first master the bowling game kata before applying TDD to a mini-project by developing a component with tests written using a framework like JUnit.

Uploaded by

Fabian Vargas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Test

 Driven  Development  

So#ware  Quality  
Quality  Audit  and  Cer6fica6on  
 
Master  in  Computer  Engineering  
 
 
Roberto  García  ([email protected])  
 
 
Introduc6on  
•  Tes6ng  is  the  most  popular  quality-­‐improvement  
ac6vity.  
•  SoGware  is  tested  in  numerous  ways,  some  
performed  by  developers  and  others  by  
specialized  test  personnel.  
•  Simplest  developer  tes:ng:  
–  Unit  tes:ng:  the  execu6on  of  a  complete  class,  
rou6ne  or  small  program.    
•  WriOen  by  a  single  programmer  or  team  of  programmers.    
•  Tested  in  isola:on  from  the  complete  system.    
Introduc6on  
•  Design  the  test  cases  along  with  the  product  
to  find  defects  as  early  as  possible  
•  Advantages  of  wri6ng  test  cases  first:  
–  Detect  defects  earlier.  
–  Forces  to  think  at  least  a  liOle  bit  about  the  
requirements  and  design  before  wri6ng  code.  
–  Wri6ng  test  cases  first  exposes  requirements  
problems  sooner  because  it's  hard  to  write  a  test  
case  for  a  poor  requirement.  
Introduc6on  
•  Test-­‐driven  development  (TDD)  is  a  development  
technique  where  you  must  first  write  a  test  that  
fails  before  you  write  new  func6onal  code.  
•  Complementary  to  Agile  development  
–  Methods  based  on  itera:ve  and  incremental  
development,  where  requirements  and  solu6ons  
evolve  
•  Not  a  replacement  for  tradi6onal  tes6ng,  a  
proven  way  to  ensure  effec6ve  unit  tes6ng.  
Introduc6on  
•  TDD  requires  a  tes:ng  framework.      
•  OGen  the  xUnit  family  of  open  source  tools  
–  JUnit:  the  framework  for  Java  
•  TDD  encourages  small  steps  when  wri6ng  
soGware  
–  It  is  much  easier  to  find,  and  then  fix,  defects  
Learning-­‐by-­‐doing  
•  Kata  (型  or  形  literally:  "form”)    
–  Thee  Japanese  word  describing  detailed  
choreographed  paOerns  of  movements  to  be  
prac6sed.  
Learning-­‐by-­‐doing  
•  The  Bowling  Game  Kata  
–  hOp://butunclebob.com/
Ar6cleS.UncleBob.TheBowlingGameKata    
–  A  kata  is  meant  to  be  memorized.    
–  It  is  not  the  conclusion  of  the  kata  that  maOers,  it's  the  steps  
that  lead  to  the  conclusion.    
–  As  you  learn  the  form,  and  repeat  it,  and  repeat  it,  you  will  
condi6on  your  mind  and  body  to  respond  the  way  I  respond  to  
the  minute  factors  that  lead  to  design  decisions.  
–  I  have  broken  the  kata  up  into  five  short  sec:ons.  Fully  learn  
one  sec:on  before  adding  the  next.    
–  Don't  learn  the  next  un6l  you  have  mastered  the  previous.  A  
kata  needs  to  seep  into  your  bones,  and  this  take  6me.  
Learning-­‐by-­‐doing  
•  The  Bowling  Game  Kata  
–  Presenta6on:  
hOp://butunclebob.com/files/downloads/Bowling
%20Game%20Kata.ppt    
•  Addi:onal  resources:  “Bowling  Game  Kata.ppt”  
–  Videos:  
•  hOp://www.youtube.com/watch?v=2PfXbKIDbKw    
(C#,  Visual  Studio)  
•  hOp://www.youtube.com/watch?v=igywEzPJRsM  
(Java,  Eclipse)  
Exercise  
•  First  of  all,  master  the    
“Bowling  Game  Kata”  ;-­‐)  

•  For  your  mini-­‐project,  try  to  develop  at  least  


one  component  using  the  TDD  approach  
–  Using  xUnit,  for  instance  JUnit  in  Java  
•  Addi:onal  resources:  “AES’11-­‐12_Tes6ng.pdf”  

You might also like