Upgrade to Pro — share decks privately, control downloads, hide ads and more …

TDD/BDD

 TDD/BDD

Test-Driven Development

Shintaro Kaneko

October 23, 2014
Tweet

More Decks by Shintaro Kaneko

Other Decks in Programming

Transcript

  1. Agenda 4 What is TDD? 4 TDD life-cycle 4 How

    to play TDD? (Demo) 4 What is BDD? 4 What is the difference between BDD and TDD? 4 How to manipulate BDD? (Demo) © kaneshin, 2014 2
  2. TDD means Test-Driven Development. 4 Ensure your source code. 4

    Understand the feature's specification/s and requirement/s. 4 Easily to adopt Agile for your project. 4 ... © kaneshin, 2014 4
  3. TDD is NOT about testing. 4 TDD is about Development.

    4 It's all about expressing intent. 4 Specifically, improving your project. 4 Covering unit tests powerfully. © kaneshin, 2014 5
  4. 1. Write a test (Test-First) 2. Run the test (Should

    be FAILED) 3. Write code (Make the test pass) 4. Run all tests 5. Refactor (Clean up code) Repeat © kaneshin, 2014 7
  5. 1. Write a test and confirm failure 2. Write code

    to pass all tests 3. Clean up code Repeat © kaneshin, 2014 8
  6. Write a test. - (void)testAdd3To4 { Calc *calc = [Calc

    new]; XCTAssertEqualWithAccuracy( [calc add:3 to:4], 7, .001 ); } 4 Should be failed on build because there is no implementation. © kaneshin, 2014 10
  7. Write code @interface Calc : NSObject - (double)add:(double)a to:(double)b; @end

    @implementation Calc - (double)add:(double)a to:(double)b { return 0.; } @end © kaneshin, 2014 11
  8. Make the test pass @implementation Calc - (double)add:(double)a to:(double)b {

    return 7.; } @end 4 Just enough code to pass. © kaneshin, 2014 12
  9. Got it? 4 Memorize the figure 4 Test-First 4 Should

    be failed 4 Refactor, Refactor, Refactor © kaneshin, 2014 14
  10. Wizard Spec (ຐ๏࢖͍) 4 Level 1 : ௨ৗ߈ܸ͕Ͱ͖Δ (Attack: 1

    Damage) 4 Level 3 : Ϊϥ͕࢖͑Δ (Sizz: 2 Damage) 4 Level 5 : ϝϥϛ͕࢖͑Δ (Frizzle: 2 Damage) 4 Level up ʹ͸Exp 30͕Ұ཯Ͱඞཁ (؆ศͷͨΊ) © kaneshin, 2014 17
  11. Slime Spec (εϥΠϜ) 4 Life: 2, Exp: 10 Goblin Spec

    (ΰϒϦϯ) 4 Life: 5, Exp: 30 ※Ϟϯελʔ͸Ұ౓ܦݧ஋Λऔಘ͞ΕΔͱExp͸0ͱͳΔ © kaneshin, 2014 18
  12. The difference between BDD and TDD? 4 TDD is focused

    How on code. 4 Just satisfied spec/s and requirement/s. 4 We wanna confirm a state transition. 4 A State is transitioning every-time. 4 Test-suites might have scenes on conditions. 4 BDD can check the validity of scenes. © kaneshin, 2014 22