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

BDD NL

BDD NL

My talk on BDD from Cocoaheads NL given on 15.03.2017

Pawel Dudek

March 16, 2017
Tweet

More Decks by Pawel Dudek

Other Decks in Programming

Transcript

  1. A method by which individual units of source code, sets

    of one or more program modules together with associated control data, usage procedures, and operating procedures are tested to determine if they are fit for use. --Kolawa, Adam; Huizinga, Dorota (2007) @eldudi 10
  2. A method by which individual units of source code, sets

    of one or more program modules together with associated control data, usage procedures, and operating procedures are tested to determine if they are fit for use. --Kolawa, Adam; Huizinga, Dorota (2007) @eldudi 12
  3. An app is a set of behaviors created by programmer

    and expected by user. @eldudi 14
  4. We can’t always ‘load’ all of the code of our

    app into our memory. @eldudi 16
  5. Good design » High cohesion » Low coupling » Easily

    composable » Context independent @eldudi 41
  6. Good architecture - principles » Single responsibility » Few dependencies

    » Depend on interfaces, not classes (yay POP!) @eldudi 42
  7. SOLID Homework » Goruco 2009 - SOLID Object-Oriented Design -

    Sandi Metz » MCE^3 - Software Paradigms & Patterns — Did We Get It All Wrong? - Jon Reid » MCE^3 - Jorge Ortiz » Clean Architecture - Uncle Bob @eldudi 47
  8. class DolphinSpec: QuickSpec { override func spec() { it("is friendly")

    { expect(Dolphin().isFriendly).to(beTruthy()) } it("is smart") { expect(Dolphin().isSmart).to(beTruthy()) } } }
  9. describe("a dolphin") { describe("its click") { it("is loud") { let

    click = Dolphin().click() expect(click.isLoud).to(beTruthy()) } it("has a high frequency") { let click = Dolphin().click() expect(click.hasHighFrequency).to(beTruthy()) } } }
  10. describe("a dolphin") { var dolphin: Dolphin! beforeEach { dolphin =

    Dolphin() } describe("its click") { var click: Click! beforeEach { click = dolphin.click() } it("is loud") { expect(click.isLoud).to(beTruthy()) } it("has a high frequency") { expect(click.hasHighFrequency).to(beTruthy()) } } }
  11. describe("its click") { context("when the dolphin is not near anything

    interesting") { it("is only emitted once") { expect(dolphin!.click().count).to(equal(1)) } }
  12. describe("its click") { context("when the dolphin is near something interesting")

    { beforeEach { let ship = SunkenShip() Jamaica.dolphinCove.add(ship) Jamaica.dolphinCove.add(dolphin) } it("is emitted three times") { expect(dolphin.click().count).to(equal(3)) } } }
  13. BDD - recap » Tests influence your architecture » No

    such thing as untestable behavior » Think examples/behaviors, not tests » Don’t test implementation, work outside-in » Use ubiquitous language to make examples easily understandable @eldudi 67