24
TDD / BDD Intr oducing with Objective-C using X CT est © kaneshin, 2014 1

TDD/BDD - Introducing with Objective-C using XCTest

Embed Size (px)

DESCRIPTION

TDD/BDD - Introducing with Objective-C using XCTest

Citation preview

Page 1: TDD/BDD - Introducing with Objective-C using XCTest

TDD / BDDIntroducing with Objective-C using XCTest

© kaneshin, 2014 1

Page 2: TDD/BDD - Introducing with Objective-C using XCTest

Agenda4 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

Page 3: TDD/BDD - Introducing with Objective-C using XCTest

What is TDD?

© kaneshin, 2014 3

Page 4: TDD/BDD - Introducing with Objective-C using XCTest

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

Page 5: TDD/BDD - Introducing with Objective-C using XCTest

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

Page 6: TDD/BDD - Introducing with Objective-C using XCTest

TDD life-cycle

© kaneshin, 2014 6

Page 7: TDD/BDD - Introducing with Objective-C using XCTest

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

Page 8: TDD/BDD - Introducing with Objective-C using XCTest

1. Write a test and confirm failure

2. Write code to pass all tests

3. Clean up code

Repeat

© kaneshin, 2014 8

Page 9: TDD/BDD - Introducing with Objective-C using XCTest

For exampleJust Adding Calculator

Add A to B

© kaneshin, 2014 9

Page 10: TDD/BDD - Introducing with Objective-C using XCTest

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

Page 11: TDD/BDD - Introducing with Objective-C using XCTest

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

Page 12: TDD/BDD - Introducing with Objective-C using XCTest

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

Page 13: TDD/BDD - Introducing with Objective-C using XCTest

Refine the code

@implementation Calc- (double)add:(double)a to:(double)b { return a + b;}@end

4 Run all tests.

© kaneshin, 2014 13

Page 14: TDD/BDD - Introducing with Objective-C using XCTest

Got it?

4 Memorize the figure

4 Test-First

4 Should be failed

4 Refactor, Refactor, Refactor

© kaneshin, 2014 14

Page 15: TDD/BDD - Introducing with Objective-C using XCTest

How to play TDD?Demo (Japanese)

© kaneshin, 2014 15

Page 16: TDD/BDD - Introducing with Objective-C using XCTest

Wizard Role-Play魔法使いのロールプレイ

© kaneshin, 2014 16

Page 17: TDD/BDD - Introducing with Objective-C using XCTest

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

Page 18: TDD/BDD - Introducing with Objective-C using XCTest

Slime Spec (スライム)

4 Life: 2, Exp: 10

Goblin Spec (ゴブリン)

4 Life: 5, Exp: 30

※モンスターは一度経験値を取得されるとExpは0となる

© kaneshin, 2014 18

Page 19: TDD/BDD - Introducing with Objective-C using XCTest

What is BDD?

© kaneshin, 2014 19

Page 20: TDD/BDD - Introducing with Objective-C using XCTest

BDD means Behavior-Driven Development.

4 Basically, it is based on TDD.

© kaneshin, 2014 20

Page 21: TDD/BDD - Introducing with Objective-C using XCTest

What is the difference between BDD and TDD?

© kaneshin, 2014 21

Page 22: TDD/BDD - Introducing with Objective-C using XCTest

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

Page 23: TDD/BDD - Introducing with Objective-C using XCTest

How to manipulate BDD?Demo (Japanese)

© kaneshin, 2014 23

Page 24: TDD/BDD - Introducing with Objective-C using XCTest

Thanks

© kaneshin, 2014 24