BDD / Specification by example

20
Specification by Example (BDD)

Transcript of BDD / Specification by example

Page 1: BDD / Specification by example

Specification by Example (BDD)

Page 2: BDD / Specification by example

Agenda

• Software Development Challenges

• BDD to the Rescue

• Spec Examples

• Automation Tools

Page 3: BDD / Specification by example

Creating software products is challenging…

Page 4: BDD / Specification by example

requirements codeS P

Cliqz

Cost of translation

years

weeks

Page 5: BDD / Specification by example
Page 6: BDD / Specification by example

Behaviour Driven Development

BDD is about eliminating Translation cost from business to developers

using the language of examples

Page 7: BDD / Specification by example

business goalsspecifying

Page 8: BDD / Specification by example

deriving scope

Page 9: BDD / Specification by example

collaboratively specifyexamples

Page 10: BDD / Specification by example

refining specification

Page 11: BDD / Specification by example

automatedvalidation of specifications

Page 12: BDD / Specification by example

building

living documentation

Page 13: BDD / Specification by example

requirements codeS P

years

weeks

Cost of translation

examples

BDD

${ } { }

DDD

Page 14: BDD / Specification by example

Spec examples

Page 15: BDD / Specification by example

What makes a good test

• In domain language

• Easy to understand

• Precise and testable

• Self-explanatory

• Consistent

Page 16: BDD / Specification by example

evaluation scenarios

Page 17: BDD / Specification by example

3D-secure v1Feature: 3d Secure

In order to reduce chargeback costsAs a system ownerI want players to go through 3D secure enrollment and verification

BackgroundGiven the card number 4236754 is enrolledAnd the card number 2341238 is not enrolled

Scenario: Enrolled cardGiven the player has a card with number 4236754

And expiry date 12 11And address line 1 Max Weber Platz 23And address line 2 1st floorAnd post code 12300And city VienaAnd country AustriaWhen the player starts a transaction for 10 EURThen the system will send a message “””

<message type=“ENROLMENT_CHK_MSG”><CARD> 4236754</CARD>

</message>“””And the system will receive a response “””

<response><ENROLEMENT_CHK>enrolled</

ENROLEMENT_CHK></response>

“””

Page 18: BDD / Specification by example

3D-secure v1Then the system will send a message “””<message type=“3D_AUTHORIZE”>

<CARD>4236754</CARD><EXPIRY>1211</EXPIRY><ADDRESS_LINE1>Max Weber Platz

23</ADDRESS_LINE_1><ADDRESS_LINE2>1st floor</ADDRESS_LINE_1><POST_CODE>12300</POST_CODE><CITY>VIENNA</CITY><COUNTRY>AUSTRIA</COUNTRY>

</message>“””And the system will receive a response “””

<response><AUTHORIZE>

<3D_SECURE_URL>http://hsbc.co.uk</3D_SECURE_URL><PA_REQ>232325454-444444232323232</PA_REQ>

</AUTHORIZE></response>

“””And the system will redirect the user to http://hsbc.co.ukAnd the PA-REQ code in the form will be 232325454-

444444232323232

Page 19: BDD / Specification by example

3D-secure v2

Feature: Card enrollment with 3d SecureIn order to reduce chargeback costsAs a system ownerI want players to go through 3D secure enrollment and

verificationbefore proceeding with actual authorization

Scenario Outline: 3d transaction processingGiven the card was <enrolled>

And 3D Secure gateway response was <response>Then the transaction status is <status>

Examples: Response arrived

Examples: still waiting for response

Examples: card not enrolled, so not going through 3D at all

enrolled response status YES cancel CANCELLED

YES authorize PENDING_AUTHORIZATION

enrolled response status YES not received yet PENDING 3D SECURE

enrolled response status NO not received yet PENDING AUTHORIZATION

Page 20: BDD / Specification by example

Automation tools

• Cucumber: http://cucumber.io

• JBehave: http://jbehave.org

• SpecFlow: http://www.specflow.org

• Appium: http://appium.io/