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

Building Behavior Driven Teams - PHPCon Poland 2014

Karol Sójko
September 24, 2014

Building Behavior Driven Teams - PHPCon Poland 2014

Many teams in their development process tend to focus on answering the question “how” instead of “why”. This leads to many misunderstandings which in turn decrease productivity and pleasure of working.
In my presentation I waned to introduce Behavior Driven Development which is one of the ways to improve communication within a team. I will share my knowledge on how to start with BDD in your company and say a couple of words about things like StoryBDD, SpecBDD and living documentation. Taking my team as a use case I will also speak about how BDD helped us in understanding each other and making software that matters.

Karol Sójko

September 24, 2014
Tweet

More Decks by Karol Sójko

Other Decks in Programming

Transcript

  1. Karol Sójko Project Leader @ Schibsted Tech Polska @karolsojko PHPers

    3City organiser + " Ö [email protected] #BDD #PHP #Symfony #TDD #ImpactMapping #Agile #Team
  2. Full Stack BDD V Behavior Driven Development Inner Quality X

    Outer Quality Quality Spec BDD Story BDD
  3. Increase Books Sale Readers Organize Events What Authors Make Book

    Clubs Popular What What … … Impact Mapping
  4. Increase Books Sale Readers Organize Events Inviting Readers Authors Make

    Book Clubs Popular Voting for books Creating book clubs … … Impact Mapping
  5. Increase Books Sale Readers Organize Events Inviting Readers Authors Make

    Book Clubs Popular Voting for books Creating book clubs … … Scenario Workshop Feature: Creating book clubs
 In order to make book clubs popular
 As a reader
 I want to create book clubs
 
 Scenario: Successfully creating a book club
 Given I am a registered user
 When I create a book club
 Then all users can join it
  6. Increase Books Sale Readers Organize Events Inviting Readers Authors Make

    Book Clubs Popular Voting for books Creating book clubs … … Refine Examples Before Given I am a registered user
 When I create a book club
 Then all users can join it Given I am logged in as “[email protected]”
 When I am on book club creation page
 And I fill in “Name” with “PHP Book Club”
 And I press “Create”
 Then a pubic book club “PHP Book Club” should exist ! After
  7. /**
 * @Then a public book club :bookClubName should exist


    */
 public function aPublicBookClubShouldExist($bookClubName)
 {
 $dm = $this->getDocumentManager();
 $bookClub = $dm->getRepository('AcmeDemoBundle:BookClub')
 ->findOneBy(array('email' => $bookClubName));
 
 if (empty($bookClub)) {
 throw new \Exception(sprintf(
 'Book club %s has not been found',
 $bookClubName
 ));
 }
 } Behat steps
  8. use PhpSpec\ObjectBehavior;
 
 class BookClubSpec extends ObjectBehavior
 {
 /**
 *

    @param Acme\DemoBundle\Document\User $user
 */
 function it_should_be_available_for_readers($user)
 {
 $user->isReader()->willReturn(true);
 
 $this->isAvailableFor($user)->shouldReturn(true);
 }
 
 /**
 * @param Acme\DemoBundle\Document\User $user
 */
 function it_should_not_be_available_for_readers_if_premium($user)
 {
 $user->isReader()->willReturn(true);
 $this->setPremium(true);
 
 $this->isAvailableFor($user)->shouldReturn(false);
 }
 
 } class BookClub
 {
 protected $premium;
 
 /**
 * @param $premium
 */
 public function setPremium($premium)
 {
 $this->premium = $premium;
 }
 
 /**
 * @param User $user
 *
 * @return bool
 */
 public function isAvailableFor(User $user)
 {
 return $user->isReader() && !$this->premium;
 }
 } PhpSpec Implementation