Professional Documents
Culture Documents
BDD strives to avoid the traditional disconnect between Business people and Technology people through use of a common vocabulary for describing the system.
Programmers...
Why do I need to write tests? Thats what testers do. Writing all these tests slows me down! Its a waste of my time. Im a good programmer! I dont need to write tests to prove my code works.
Testers...
Why are programmers writing tests? We all know they cant thats why you need testers! Are you trying to take away our jobs? You obviously dont understand testing or you wouldnt be asking programmers write tests!
Enough is Enough
Traditional large up-front design requires asking the most important questions at a time when the team has the least amount of knowledge. This often requires making wild guesses about the design, and scope, of a system before anyone even understands the product being built.
Embrace Change
BDD/TDD strives to describe just enough of the system to deliver something useful. We call this the Red, Green, Refactor cycle. Change is not only accepted, but is expected. It is integrated directly into an agile planning and development process.
Cedar
BDD Framework by Pivotal Labs
http://github.com/pivotal/cedar
Describe It!
SPEC_BEGIN(FooSpec) describe(@"Foo", ^{ beforeEach(^{ ... }); it(@"should be awesome", ^{ ... }); }); SPEC_END
OCHamcrest
Matcher Library for Objective-C
http://code.google.com/p/hamcrest/wiki/TutorialObjectiveC
Assert That!
NSString *myString = @"Foo"; assertThat(myString, equalTo(@"Foo")); ...or with a little syntactic sugar... assertThat(myString, is(equalTo(@"Foo"))); assertThat(myString, is(@"Foo"));
Common Matchers
Core: anything, describedAs, is Logical: allOf, anyOf, isNot Object: equalTo, hasDescription, instanceOf, isCompatableType, nilValue, notNilValue, sameInstance Collections: hasEntry, hasKey, hasValue, hasItem, hasItems Number: closeTo, greaterThan, greaterThanOrEqualTo, etc. Text: equalToIgnoringCase, equalToIgnoringWhiteSpace, containsString, startsWith, endsWith
OCMock
Sometimes You Just Need to Fake It!
http://www.mulle-kybernetik.com/software/OCMock/
mock = [OCMockObject partialMockForObject:gr]; [[[mock expect] andReturn:@"I'm a fake response"] post:[OCMArg any]];
// Send a message to the real GRReader instance
Like OCHamcrest, OCMock can be used with any test framework you like.
Demos...
A Jasmine Spec...
describe("Player", function() { !!var player; !!var song; !!beforeEach(function() { !!!!player = new Player(); !!!!song = new Song(); !!}); !!it("should be able to play a Song", function() { !!!!player.play(song); !!!!expect(player.currentlyPlayingSong).toEqual(song); !!}); });
This work is licensed under the Creative Commons Attribution 3.0 United States License. To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/us/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.