SlideShare uma empresa Scribd logo
1 de 10
Baixar para ler offline
BDD for iOS with Kiwi
     Oleksandr Gnatyshyn
Why BDD? Why Kiwi?

Kiwi is BDD library for iOS, «RSpec» like, easy to
                 setup and use.



      Kiwi               Kiwi built on top of OCUnit
                         and tightly integrated with
                         Xcode!
     OCUnit
Why BDD? Why Kiwi?
TDD - OCUnit :                                    BDD - Kiwi :
@implementation testTests
                                                  describe(@"Team", ^{
                                                      context(@"when newly created", ^{
- (void)testThatTeamShouldHaveName
                                                          it(@"should have a name", ^{
{
                                                              id team = [Team team];
    id team = [Team team];
                                                                    [[team.name should] equal:@"Black Hawks"];
    STAssertEqualObjects(team.name, @"Black
                                                              });
Hawks", @"Team shuld have a name");
                                                        });
                                                  });
}




1. Design                                         1. Nice structure
                                              +
2. Test Logic                                     2. Better Assertions
Kiwi installation


 •   Old School way -
     https://github.com/allending/Kiwi/wiki/Guide:-Up-and-Running-with-Kiwi




 •   Easy way - CocoaPods!!
//Podfile
platform :ios
  target :KiwiUnitTest, :exclusive => true do
      pod 'Kiwi'
  end
Basic usage
                                                                • SPEC_BEGIN(ClassName) and SPEC_END -
SPEC_BEGIN(SpecName)
                                                                macros that expand to begin and end a KWSpec class
describe(@"ClassName", ^{                                       and group declaration.

      context(@"a state the component is in", ^{
          __block id variable = nil;

            beforeAll(^{ // Occurs once
            });

            afterAll(^{ // Occurs once
            });

            beforeEach(^{ // Occurs before each enclosed "it"
                variable = [MyClass instance];
            });

            afterEach(^{ // Occurs after each enclosed "it"
            });

            it(@"should do something", ^{
                [[variable should] meetSomeExpectation];
            });

            context(@"inner context", ^{
                xit(@"does another thing", ^{
                });

                 pending(@"something unimplemented", ^{
                 });
            })
      });
});

SPEC_END
Basic usage
                                                                • SPEC_BEGIN(ClassName) and SPEC_END -
SPEC_BEGIN(SpecName)
                                                                macros that expand to begin and end a KWSpec class
describe(@"ClassName", ^{                                       and group declaration.

      context(@"a state the component is in", ^{                • describe(aString, aBlock) - starts a context that can
          __block id variable = nil;                            contain tests and nested contexts.
            beforeAll(^{ // Occurs once
            });                                                 • context(aString, aBlock) - synonym for describe.
            afterAll(^{ // Occurs once
            });

            beforeEach(^{ // Occurs before each enclosed "it"
                variable = [MyClass instance];
            });

            afterEach(^{ // Occurs after each enclosed "it"
            });

            it(@"should do something", ^{
                [[variable should] meetSomeExpectation];
            });

            context(@"inner context", ^{
                xit(@"does another thing", ^{
                });

                 pending(@"something unimplemented", ^{
                 });
            })
      });
});

SPEC_END
Basic usage
                                                                • SPEC_BEGIN(ClassName) and SPEC_END -
SPEC_BEGIN(SpecName)
                                                                macros that expand to begin and end a KWSpec class
describe(@"ClassName", ^{                                       and group declaration.

      context(@"a state the component is in", ^{                • describe(aString, aBlock) - starts a context that can
          __block id variable = nil;                            contain tests and nested contexts.
            beforeAll(^{ // Occurs once
            });                                                 • context(aString, aBlock) - synonym for describe.
            afterAll(^{ // Occurs once
            });                                                 • beforeAll(aBlock), afterAll(aBlock) - run once
            beforeEach(^{ // Occurs before each enclosed "it"
                                                                before and after all the inner contexts and it blocks of
                variable = [MyClass instance];                  the context it is in.
            });

            afterEach(^{ // Occurs after each enclosed "it"     • beforeEach(aBlock), afterEach(aBlock) - run before
            });                                                 and after every it block in all enclosed contexts.
            it(@"should do something", ^{
                [[variable should] meetSomeExpectation];        • it(aString, aBlock) - This is where actual actual
            });
                                                                expectations on objects should go
            context(@"inner context", ^{
                xit(@"does another thing", ^{
                });

                 pending(@"something unimplemented", ^{
                 });
            })
      });
});

SPEC_END
Basic usage
                                                                • SPEC_BEGIN(ClassName) and SPEC_END -
SPEC_BEGIN(SpecName)
                                                                macros that expand to begin and end a KWSpec class
describe(@"ClassName", ^{                                       and group declaration.

      context(@"a state the component is in", ^{                • describe(aString, aBlock) - starts a context that can
          __block id variable = nil;                            contain tests and nested contexts.
            beforeAll(^{ // Occurs once
            });                                                 • context(aString, aBlock) - synonym for describe.
            afterAll(^{ // Occurs once
            });                                                 • beforeAll(aBlock), afterAll(aBlock) - run once
            beforeEach(^{ // Occurs before each enclosed "it"
                                                                before and after all the inner contexts and it blocks of
                variable = [MyClass instance];                  the context it is in.
            });

            afterEach(^{ // Occurs after each enclosed "it"     • beforeEach(aBlock), afterEach(aBlock) - run before
            });                                                 and after every it block in all enclosed contexts.
            it(@"should do something", ^{
                [[variable should] meetSomeExpectation];        • it(aString, aBlock) - This is where actual actual
            });
                                                                expectations on objects should go
            context(@"inner context", ^{
                xit(@"does another thing", ^{
                });
                                                                • pending(aString, aBlock), xit(aString, aBlock) -
                                                                doesn't do anything other than log a pending message
                 pending(@"something unimplemented", ^{         to the output when run.
                 });
            })
      });
});

SPEC_END
DEMO
Thanks!

•   Kiwi repo - https://github.com/allending/Kiwi

•   NSScreencast(episode about kiwi) - http://nsscreencast.com/
    episodes/4-automated-testing-with-kiwi


•   Test Driving iOS Development with Kiwi by Daniel H
    Steinberg - iBooks Store Link

Mais conteúdo relacionado

Mais procurados

TKPJava - Teaching Kids Programming - Core Java Langauge Concepts
TKPJava - Teaching Kids Programming - Core Java Langauge ConceptsTKPJava - Teaching Kids Programming - Core Java Langauge Concepts
TKPJava - Teaching Kids Programming - Core Java Langauge ConceptsLynn Langit
 
Java Search Engine Framework
Java Search Engine FrameworkJava Search Engine Framework
Java Search Engine FrameworkAppsterdam Milan
 
Buenos Aires Drools Expert Presentation
Buenos Aires Drools Expert PresentationBuenos Aires Drools Expert Presentation
Buenos Aires Drools Expert PresentationMark Proctor
 
Pragmatic unittestingwithj unit
Pragmatic unittestingwithj unitPragmatic unittestingwithj unit
Pragmatic unittestingwithj unitliminescence
 
A clean(er) architecture
A clean(er) architectureA clean(er) architecture
A clean(er) architectureAndreaMaglie
 
Java 7 + 8 new features
Java 7 + 8 new featuresJava 7 + 8 new features
Java 7 + 8 new featuresgurilivne
 

Mais procurados (10)

Candidacy
CandidacyCandidacy
Candidacy
 
TKPJava - Teaching Kids Programming - Core Java Langauge Concepts
TKPJava - Teaching Kids Programming - Core Java Langauge ConceptsTKPJava - Teaching Kids Programming - Core Java Langauge Concepts
TKPJava - Teaching Kids Programming - Core Java Langauge Concepts
 
Java Search Engine Framework
Java Search Engine FrameworkJava Search Engine Framework
Java Search Engine Framework
 
Buenos Aires Drools Expert Presentation
Buenos Aires Drools Expert PresentationBuenos Aires Drools Expert Presentation
Buenos Aires Drools Expert Presentation
 
ERRest and Dojo
ERRest and DojoERRest and Dojo
ERRest and Dojo
 
Pragmatic unittestingwithj unit
Pragmatic unittestingwithj unitPragmatic unittestingwithj unit
Pragmatic unittestingwithj unit
 
A clean(er) architecture
A clean(er) architectureA clean(er) architecture
A clean(er) architecture
 
Java 7 + 8 new features
Java 7 + 8 new featuresJava 7 + 8 new features
Java 7 + 8 new features
 
JRuby hacking guide
JRuby hacking guideJRuby hacking guide
JRuby hacking guide
 
4 gouping object
4 gouping object4 gouping object
4 gouping object
 

Semelhante a Bdd for ios with kiwi

Spock: A Highly Logical Way To Test
Spock: A Highly Logical Way To TestSpock: A Highly Logical Way To Test
Spock: A Highly Logical Way To TestHoward Lewis Ship
 
AST Transformations
AST TransformationsAST Transformations
AST TransformationsHamletDRC
 
Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)HamletDRC
 
Introducing CakeEntity
Introducing CakeEntityIntroducing CakeEntity
Introducing CakeEntityBasuke Suzuki
 
Stepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to ScalaStepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to ScalaDerek Chen-Becker
 
Java Concurrency Gotchas
Java Concurrency GotchasJava Concurrency Gotchas
Java Concurrency GotchasAlex Miller
 
Ast transformations
Ast transformationsAst transformations
Ast transformationsHamletDRC
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotationjavatwo2011
 
Ts archiving
Ts   archivingTs   archiving
Ts archivingConfiz
 
Introduction to Scala : Clueda
Introduction to Scala : CluedaIntroduction to Scala : Clueda
Introduction to Scala : CluedaAndreas Neumann
 
New Features Of JDK 7
New Features Of JDK 7New Features Of JDK 7
New Features Of JDK 7Deniz Oguz
 
iOS Behavior-Driven Development
iOS Behavior-Driven DevelopmentiOS Behavior-Driven Development
iOS Behavior-Driven DevelopmentBrian Gesiak
 
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...julien.ponge
 
Akka Actor presentation
Akka Actor presentationAkka Actor presentation
Akka Actor presentationGene Chang
 
Class loader basic
Class loader basicClass loader basic
Class loader basic명철 강
 
Scala uma poderosa linguagem para a jvm
Scala   uma poderosa linguagem para a jvmScala   uma poderosa linguagem para a jvm
Scala uma poderosa linguagem para a jvmIsaias Barroso
 

Semelhante a Bdd for ios with kiwi (20)

Spock: A Highly Logical Way To Test
Spock: A Highly Logical Way To TestSpock: A Highly Logical Way To Test
Spock: A Highly Logical Way To Test
 
AST Transformations
AST TransformationsAST Transformations
AST Transformations
 
Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)
 
Workshop Scala
Workshop ScalaWorkshop Scala
Workshop Scala
 
Introducing CakeEntity
Introducing CakeEntityIntroducing CakeEntity
Introducing CakeEntity
 
Stepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to ScalaStepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to Scala
 
Java Concurrency Gotchas
Java Concurrency GotchasJava Concurrency Gotchas
Java Concurrency Gotchas
 
Groovy Testing
Groovy TestingGroovy Testing
Groovy Testing
 
Ast transformations
Ast transformationsAst transformations
Ast transformations
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
 
Ts archiving
Ts   archivingTs   archiving
Ts archiving
 
Introduction to Scala : Clueda
Introduction to Scala : CluedaIntroduction to Scala : Clueda
Introduction to Scala : Clueda
 
New Features Of JDK 7
New Features Of JDK 7New Features Of JDK 7
New Features Of JDK 7
 
iOS Behavior-Driven Development
iOS Behavior-Driven DevelopmentiOS Behavior-Driven Development
iOS Behavior-Driven Development
 
Jasmine BDD for Javascript
Jasmine BDD for JavascriptJasmine BDD for Javascript
Jasmine BDD for Javascript
 
JS OO and Closures
JS OO and ClosuresJS OO and Closures
JS OO and Closures
 
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
 
Akka Actor presentation
Akka Actor presentationAkka Actor presentation
Akka Actor presentation
 
Class loader basic
Class loader basicClass loader basic
Class loader basic
 
Scala uma poderosa linguagem para a jvm
Scala   uma poderosa linguagem para a jvmScala   uma poderosa linguagem para a jvm
Scala uma poderosa linguagem para a jvm
 

Bdd for ios with kiwi

  • 1. BDD for iOS with Kiwi Oleksandr Gnatyshyn
  • 2. Why BDD? Why Kiwi? Kiwi is BDD library for iOS, «RSpec» like, easy to setup and use. Kiwi Kiwi built on top of OCUnit and tightly integrated with Xcode! OCUnit
  • 3. Why BDD? Why Kiwi? TDD - OCUnit : BDD - Kiwi : @implementation testTests describe(@"Team", ^{ context(@"when newly created", ^{ - (void)testThatTeamShouldHaveName it(@"should have a name", ^{ { id team = [Team team]; id team = [Team team]; [[team.name should] equal:@"Black Hawks"]; STAssertEqualObjects(team.name, @"Black }); Hawks", @"Team shuld have a name"); }); }); } 1. Design 1. Nice structure + 2. Test Logic 2. Better Assertions
  • 4. Kiwi installation • Old School way - https://github.com/allending/Kiwi/wiki/Guide:-Up-and-Running-with-Kiwi • Easy way - CocoaPods!! //Podfile platform :ios target :KiwiUnitTest, :exclusive => true do pod 'Kiwi' end
  • 5. Basic usage • SPEC_BEGIN(ClassName) and SPEC_END - SPEC_BEGIN(SpecName) macros that expand to begin and end a KWSpec class describe(@"ClassName", ^{ and group declaration. context(@"a state the component is in", ^{ __block id variable = nil; beforeAll(^{ // Occurs once }); afterAll(^{ // Occurs once }); beforeEach(^{ // Occurs before each enclosed "it" variable = [MyClass instance]; }); afterEach(^{ // Occurs after each enclosed "it" }); it(@"should do something", ^{ [[variable should] meetSomeExpectation]; }); context(@"inner context", ^{ xit(@"does another thing", ^{ }); pending(@"something unimplemented", ^{ }); }) }); }); SPEC_END
  • 6. Basic usage • SPEC_BEGIN(ClassName) and SPEC_END - SPEC_BEGIN(SpecName) macros that expand to begin and end a KWSpec class describe(@"ClassName", ^{ and group declaration. context(@"a state the component is in", ^{ • describe(aString, aBlock) - starts a context that can __block id variable = nil; contain tests and nested contexts. beforeAll(^{ // Occurs once }); • context(aString, aBlock) - synonym for describe. afterAll(^{ // Occurs once }); beforeEach(^{ // Occurs before each enclosed "it" variable = [MyClass instance]; }); afterEach(^{ // Occurs after each enclosed "it" }); it(@"should do something", ^{ [[variable should] meetSomeExpectation]; }); context(@"inner context", ^{ xit(@"does another thing", ^{ }); pending(@"something unimplemented", ^{ }); }) }); }); SPEC_END
  • 7. Basic usage • SPEC_BEGIN(ClassName) and SPEC_END - SPEC_BEGIN(SpecName) macros that expand to begin and end a KWSpec class describe(@"ClassName", ^{ and group declaration. context(@"a state the component is in", ^{ • describe(aString, aBlock) - starts a context that can __block id variable = nil; contain tests and nested contexts. beforeAll(^{ // Occurs once }); • context(aString, aBlock) - synonym for describe. afterAll(^{ // Occurs once }); • beforeAll(aBlock), afterAll(aBlock) - run once beforeEach(^{ // Occurs before each enclosed "it" before and after all the inner contexts and it blocks of variable = [MyClass instance]; the context it is in. }); afterEach(^{ // Occurs after each enclosed "it" • beforeEach(aBlock), afterEach(aBlock) - run before }); and after every it block in all enclosed contexts. it(@"should do something", ^{ [[variable should] meetSomeExpectation]; • it(aString, aBlock) - This is where actual actual }); expectations on objects should go context(@"inner context", ^{ xit(@"does another thing", ^{ }); pending(@"something unimplemented", ^{ }); }) }); }); SPEC_END
  • 8. Basic usage • SPEC_BEGIN(ClassName) and SPEC_END - SPEC_BEGIN(SpecName) macros that expand to begin and end a KWSpec class describe(@"ClassName", ^{ and group declaration. context(@"a state the component is in", ^{ • describe(aString, aBlock) - starts a context that can __block id variable = nil; contain tests and nested contexts. beforeAll(^{ // Occurs once }); • context(aString, aBlock) - synonym for describe. afterAll(^{ // Occurs once }); • beforeAll(aBlock), afterAll(aBlock) - run once beforeEach(^{ // Occurs before each enclosed "it" before and after all the inner contexts and it blocks of variable = [MyClass instance]; the context it is in. }); afterEach(^{ // Occurs after each enclosed "it" • beforeEach(aBlock), afterEach(aBlock) - run before }); and after every it block in all enclosed contexts. it(@"should do something", ^{ [[variable should] meetSomeExpectation]; • it(aString, aBlock) - This is where actual actual }); expectations on objects should go context(@"inner context", ^{ xit(@"does another thing", ^{ }); • pending(aString, aBlock), xit(aString, aBlock) - doesn't do anything other than log a pending message pending(@"something unimplemented", ^{ to the output when run. }); }) }); }); SPEC_END
  • 10. Thanks! • Kiwi repo - https://github.com/allending/Kiwi • NSScreencast(episode about kiwi) - http://nsscreencast.com/ episodes/4-automated-testing-with-kiwi • Test Driving iOS Development with Kiwi by Daniel H Steinberg - iBooks Store Link