Brown Bag Lunch - BDD an introduction - 2017 feb/mar

45
2 Behavior Driven Development & Specification by Example s with @aloyer

Transcript of Brown Bag Lunch - BDD an introduction - 2017 feb/mar

2

Behavior Driven Development

&

Specification by Exampleswith

@aloyer

Mastering Software Developmentarolla.fr

Arnauld Loyer @aloyer /[TBD]DD/ fanboy

this is a

regular expression!

1. testing new functionalities

2. non-regression testing

3. having conversation

4. writing scenario and automating them

5. using Cucumber/Specflow

6. a database but in french ?!

7. other…

O

For You what is BDD About?

4@aloyer

1. Testers

2. Developers

3. DBA

4. Business/P.O.

6. Others… O

Who is concerned by BDD ?

5@aloyer

@aloyer

Read the specification What is the most important information ?

Read the specification What is the most important information ?

Interpolation is a mathematical process to estimate the value of a dependent variable based on the values of known surrounding dependent variables, where the dependent variable is a function of an independent variable. It's used to determine interest rates for periods of time that are not published or otherwise made available. In this case, the interest rate is the dependent variable, and the length of time is the independent variable. To interpolate an interest rate, you'll need the interest rate of a shorter period of time and a longer period of time.

1. Subtract the interest rate of a time period shorter than the time period of the desired interest rate from the interest rate of a time period longer than the time period of the desired interest rate.

How to Interpolate Interest Rates

2. Divide the result from Step 1 by the difference between the lengths of the two time periods.

3. Multiply the result from Step 2 by the difference between the length of time for the desired interest rate and the length of time for the interest rate with shortest length of time

4. Add the result from Step 3 to the interest rate for the shortest known time period.

The linear interpolation is an estimate for the interest rate of a specific time period, and it assumes that the interest rate changes on a straight line basis between each day. In reality, interest rates may follow a "yield curve" instead of a straight line. The estimate will be more accurate the shorter the period of time between the known interest rates you are interpolating from.

Interpolation is a mathematical process to estimate the value of a dependent variable based on the values of known surrounding dependent variables, where the dependent variable is a function of an independent variable. It's used to determine interest rates for periods of time that are not published or otherwise made available. In this case, the interest rate is the dependent variable, and the length of time is the independent variable. To interpolate an interest rate, you'll need the interest rate of a shorter period of time and a longer period of time.

1. Subtract the interest rate of a time period shorter than the time period of the desired interest rate from the interest rate of a time period longer than the time period of the desired interest rate.

How to Interpolate Interest Rates

2. Divide the result from Step 1 by the difference between the lengths of the two time periods.

3. Multiply the result from Step 2 by the difference between the length of time for the desired interest rate and the length of time for the interest rate with shortest length of time

4. Add the result from Step 3 to the interest rate for the shortest known time period.

The linear interpolation is an estimate for the interest rate of a specific time period, and it assumes that the interest rate changes on a straight line basis between each day. In reality, interest rates may follow a "yield curve" instead of a straight line. The estimate will be more accurate the shorter the period of time between the known interest rates you are interpolating from.

http://www.ehow.com/how_8396129_interpolate-interest-rates.html

http://www.modernanalyst.com/Resources/BusinessAnalystHumor/tabid/218/ID/2548/How_to_Get_Approval_from_the_Functional_Specification_Stakeholders.aspx

https://www.flickr.com/photos/ohhector/456611804

Who will read the specs? Do I write the specs for myself?

Shared documents aren’t shared understanding - @jeffpatton

http://www.math.u-bordeaux1.fr/~abachelo/enseignement.html

Why did you come here today?

@aloyer 17

shared understanding@jeffpatton

Shared documentsaren’t

C LN❝

http://defringe.com/article/kai-ziehl

Build a Shared Understanding

Three Amigos

Back to Interpolation!

23/06/2015 15:36:27 UTC

30/06/2015 23:59:60 UTC

29/06/2015 14:36:58 UTC

26/06/2015 15:36:27 UTC

24/06/2015 15:36:27 UTC

1.01.5

2.5

3.5

6.5

23/06/2015 15:36:27 UTC

30/06/2015 23:59:60 UTC

29/06/2015 14:36:58 UTC

26/06/2015 15:36:27 UTC

24/06/2015 15:36:27 UTC

1.01.5

2.5

3.5

6.5

?

23/06/2015 15:36:27 UTC

30/06/2015 23:59:60 UTC

29/06/2015 14:36:58 UTC

26/06/2015 15:36:27 UTC

24/06/2015 15:36:27 UTC

1.01.5

2.5

3.5

6.5

?

23/06/2015 15:36:27 UTC

30/06/2015 23:59:60 UTC

29/06/2015 14:36:58 UTC

26/06/2015 15:36:27 UTC

24/06/2015 15:36:27 UTC

1.01.5

2.5

3.5

5.5

5.5 - 1/3*(5.5-3.5) ≈ 4.83333333333333333

OK?

23/06/2015 15:36:27 UTC

30/06/2015 23:59:60 UTC

29/06/2015 14:36:58 UTC

26/06/2015 15:36:27 UTC

24/06/2015 15:36:27 UTC

1.01.5

2.5

3.5

5.5

~4.83333333333333333

24*60*60=86400

seconds

@aloyer 26https://pragprog.com/magazines/2012-01/the-dude-abides

having conversations is more important than capturing conversations is more important than

automating conversations - Liz Keogh

https://www.flickr.com/photos/ironrodart/8678383872/

C QExamples

LO

A P

LLLRequirements

N3 Amigos Workshop

development / tests

uat@aloyer 28

when

Show me some real examples!

23/06/2015 15:36:27 UTC

30/06/2015 23:59:60 UTC

29/06/2015 14:36:58 UTC

26/06/2015 15:36:27 UTC

24/06/2015 15:36:27 UTC

1.01.5

2.5

3.5

5.5

5.5 - 1/3*(5.5-3.5) ≈ 4.83333333333333333

OK?

@aloyer

Examples of « Horse Betting » scenario

@aloyer

Examples of « Horse Betting » scenario

@aloyer

Scenario: Without an audit, I cannot cancel a deal with a passed value date

Given I have inserted a standard OTC deal with a standard product and the following specific | price | trade date | value date | | 50 | 2014-JUL-01 | 2014-JUL-01 | When I try to cancel the deal Then I should have an error message indicating "The input is not intraday: you must provide a justification"

Scenario: Volume OTC deals

Given a standard option And a standard external OTC deal with the following specifics | way | quantity | | buy | 100 | When I create the option And I create the deal with the created product And I generate the report Volume OTC deals Then the deal should appear in the report

Examples of « CIB » scenario

@aloyer

Scenario: The portfolio position of an OTC option is properly impacted when a deal is created # # In financial trading, a position is a binding commitment to buy or sell a given amount # of financial instruments, such as securities, currencies or commodities, for a given price. # # The term "position" is also used in the context of finance for the amount of securities # or commodities held by a person, firm, or institution, and for the ownership status of # a person's or institution's investments. # # Note: strike is part of the unicity of the product; by using different strike value one # can ensure product is different among scenario Given a standard option with no specifics And a standard external OTC deal with the following specifics | portfolio | direction | quantity | | PR-GT-FR | buy | 100 | When I create the option And I check the position of the option in portfolio PR-GT-FR for TODAY And I create the deal with the created option Then the position of the option in portfolio PR-GT-FR for TODAY should be the checked position - 100

Examples of « CIB » scenario

@aloyer

Scenario: ELS - insert a CLP with a rate leg and an option leg

# L'ELS (Equity Linked Swap) est un produit dérivé modélisé en CLP (Combinaison linéaire de # produits) et permettant à deux parties de s’échanger des flux de performances et de # dividendes d’un sous-jacent equity contre un taux (jambe performance contre jambe taux).

Given a standard ELSCL PRS with the following specifics | Start date | Maturity date | End date | | 2014/02/05 | 2014/02/13 | 2014/02/13 | And with the following legs | type | numerator | | Rate | -1 | | Option | +1 | And on the following periods (with a dedicated option for each) | Start date | Constatation date | Fixing date | Payment date | End date | | 2014/02/05 | 2014/02/05 | 2015/02/05 | 2015/02/05 | 2015/02/05 | | 2015/02/05 | 2015/02/05 | 2015/02/05 | 2016/02/09 | 2016/02/09 | | 2016/02/09 | 2016/02/09 | 2016/02/09 | 2017/02/07 | 2017/02/07 | | 2017/02/07 | 2017/02/07 | 2017/02/07 | 2018/02/06 | 2018/02/06 | | 2018/02/06 | 2018/02/06 | 2018/02/06 | 2019/02/05 | 2019/02/05 | Given a standard external ELS deal with the following specifics | Trade date | Value date | Category | | 2014/02/05 | 2014/02/05 | ELSCL | When I create the ELSCL And I create an external ELS deal with the created ELSCL Then the deal should correctly be created

Examples of « CIB » scenario

https://mes-aides.gouv.fr/tests/ - 2015-MAR-16

https://mes-aides.gouv.fr/tests/ - 2015-MAR-16

https://mes-aides.gouv.fr/tests/ - 2015-MAR-16

Password OK/KO ReasonArn4uld KO No special charactersarnauld$ KO No upper caseArn4ld$ OK

Z0€ KO too short�� ?

Last Passwords Password OK/KO

J0hn$$m1th

Arn4ld$Arn4ld$ KO

J0hn$Arn4ld$$m1th

Arn4ld$ KO

Arn4ld$J0hn$$m1th

Arn4ld$ OK

Password rules…

@aloyer

@aloyer 40

Behavior

Behavior = Context + Action + Outcome

Tips

@aloyer 41

Given-When-Then

Then an outcome should be observed

Given a context

When an event happens

3 phases

setup/arrange

exercise/act

verify/assert

Tips

@aloyer 42

Given-When-Then

Then an outcome should be observed

Given a context

When an event happens

3 phases

setup/arrange

exercise/act

verify/assert

behavior

Tips

@aloyer 43

Given-When-Then

Then an outcome should be observed

Given a context

When an event happens

3 phases

Business Language Only!!!

Tips

@aloyer 44

Exercise: Scenario AnalysisScenario: A visitor can add an item to the basket

Given I am viewing a product "product/id/1" When I click "#addNowButton" Then I should see "Items added to basket"

what do you think ?

Tips

@aloyer 45

Scenario: A visitor can add an item to the basket

Given I am viewing a product "product/id/1" When I click "#addNowButton" Then I should see "Items added to basket"

Exercise: Scenario Analysis???

authenticated anonymous…

website? api? web-services?

technical details?

technical details?

Tips

@aloyer 46

In order to ease buying As a visitor I want to be able to add item in my basket

Scenario: A non authenticated visitor can add item to its basket

Given I was not yet authenticated And I had no item in my basket And I was looking at the book « Living Documentation » When I add the book in my basket Then my basket should contain the book « Living Documentation »

Scenario: A visitor can add an item to the basket

Given I am viewing a product "product/id/1" When I click "#addNowButton" Then I should see "Items added to basket"

Exercise: Scenario Analysis

only

1st… 2nd… 3rd… nth draft

Tips

@aloyer 47

In order to ease buying As a visitor I want to be able to add item in my basket

Scenario: A non authenticated visitor can add item to its basket

Given I was not yet authenticated And I had no item in my basket And I was looking at the book « Living Documentation » When I add the book in my basket Then my basket should contain the book « Living Documentation »

Exercise: Scenario Analysis

only

there is already something in the basket

the book was already in the basket it is the second time i visit the site anonymously…

a book was in the basket but not anymore available…

what if?

Tips

@aloyer 48

Scenario: A non authenticated visitor can add item to its basket

Given I was not yet authenticated And I had no item in my basket And I was looking at the book « Living Documentation » When I add the book in my basket Then my basket should contain only the book « Living Documentation »

Scenario: An authenticated visitor can add item to its basket

Given I was already authenticated as « Emma » And I had no item in my basket And I was looking at the book « Living Documentation » When I add the book in my basket Then my basket should contain only the book « Living Documentation »

Exercise: Scenario AnalysisTips