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

Pièges et difficultés du BDD : comment les résoudre ?

Pièges et difficultés du BDD : comment les résoudre ?

Marie-Laure Thuret

April 23, 2015
Tweet

More Decks by Marie-Laure Thuret

Other Decks in Programming

Transcript

  1. Le métier rédige ses propres spécifications en doublon avec les

    scénarios BDD présents dans la base de code
  2. Des détails sont présents dans le scénario même s’ils n’ont

    pas d’impact direct avec le comportement exprimé
  3. Feature: Booking a trade Scenario: when a transaction is made

    by a customer, it needs to be booked after being executed Given a customer has made a quote request for 2 tons of AH And the trader replied with an ask price at 35 and a bid price at 45 When the customer buys 2 tons of AH Then the trade should be booked
  4. Feature: Buying actions Scenario Outline: a customer buys actions at

    the trader ask price Given a customer requested to buy « <number-of-actions> » actions of « <action-name> » When the trader ask for « <trader-ask> » per action Then the customer should pay « <total-amount> » Examples: | number-of-actions | action-name | trader-ask | total-amount | | 10 | Bioware | 30 | 300 | | 10 | Rockstar | 100 | 1000 | | 5 | Quantic Dreams | 25 | 125 | | 100 | Telltales | 10 | 1000 | | 10000 | Naughty dogs | 70 | 700000 | | 10 | Electronic Arts | 2 | 20 |
  5. Feature: Buying actions Scenario: a customer buys actions at the

    trader ask price Given a customer has requested to buy "10" actions in euros of "Rockstar" When the trader ask for "30" euros each Then the customer should pay "300" euros
  6. Feature: Booking a trade Scenario: when a transaction is made

    by a customer, it needs to be booked after being executed Given the customer has received prices When the customer sends an execution request Then the transaction should be booked
  7. Feature: Buying actions Scenario: a customer buys actions at the

    trader ask price Given a customer has requested to buy "10" actions in euros. When the trader ask for "30" euros each Then the customer should pay "10 * 30" euros, i.e. "300" euros
  8. Ne pas prendre l’écriture des scénarios à la légère :

    ils garantissent les features implémentées par le système
  9. Feature: Booking a trade Scenario: when a transaction is made

    by a customer, it needs to be booked with pricing information Given the customer has sent a quote request And the trader price is : | ask | 15 | | bid | 10 | When the customer execute the quote with the way ‘Buy’ Then the booking request should have a : | client price | 15 | | trader bid | 10 | | trader ask | 15 |
  10. Monter des points réguliers pour partager les concepts métiers et

    se mettre d’accord sur l’emploi des mots à utiliser
  11. Tenir un glossaire des mots à utiliser, ainsi que ceux

    que l’on aurait volontairement mis de côté
  12. Celui qui n’est pas soigneux ou lorsque le code des

    fixtures devient pénible à maintenir
  13. Celui qui veut imiter Mac Gyver ou lorsque le développeur

    décide de privilégier l’outillage à la lisibilité des scénarios
  14. Les scénarios sont illisibles car voulant tirer au maximum parti

    des possibilités liées à l’outil BDD utilisé
  15. Feature: As the customer, I want to be able to

    send a request for a price to a pricer so I can get a price Scenario: Customer sends a price request and the pricer receive it Given a request for a price defined by "generic_price_request.json" When the customer sends the request defined by: | REQUEST_ID | CLIENT_ID | PRODUCT_INFO | TIMESTAMP | STATUS_CODE | STATUS_TEXT | TEXT | | 110e8400-e29b-11d4-a716-446655440000 | 42 | X_EUR_BMW_537389873 | 1422207807 | <null> | <null> | <null> | Then the pricer should receive a request defined by: | REQUEST_ID | CLIENT_ID | PRODUCT_INFO | TIMESTAMP | STATUS_CODE | STATUS_TEXT | TEXT | | 110e8400-e29b-11d4-a716-446655440000 | 42 | X_EUR_BMW_537389873 | 1422207807 | <null> | <null> | <null> | Scenario: Pricer sends a acknowledgment of the price request to the customer Given the pricer received a price request defined by: | REQUEST_ID | CLIENT_ID | PRODUCT_INFO | TIMESTAMP | STATUS_CODE | STATUS_TEXT | TEXT | | 110e8400-e29b-11d4-a716-446655440000 | 42 | X_EUR_BMW_537389873 | 1422207807 | <null> | <null> | <null> | When the pricer sends an acknowledgement defined by: | MESSAGE_ID | REQUEST_ID | TIMESTAMP | STATUS_CODE | STATUS_TEXT | TEXT | PRICE | | 1124d9e8-6266-4bcf-8035-37a02ba75c69 | 110e8400-e29b-11d4-a716-446655440000 | 1422219048 | 1 | ACCEPTED | <null> | <null> | Then the customer should receive a acknowledgement defined by: | MESSAGE_ID | REQUEST_ID | TIMESTAMP | STATUS_CODE | STATUS_TEXT | TEXT | PRICE | | 1124d9e8-6266-4bcf-8035-37a02ba75c69 | 110e8400-e29b-11d4-a716-446655440000 | 1422219048 | 1 | ACCEPTED | <null> | <null> | Scenario: Pricer sends a price to the customer Given the pricer sent an acknowledgement defined by: | MESSAGE_ID | REQUEST_ID | TIMESTAMP | STATUS_CODE | STATUS_TEXT | TEXT | PRICE | | 1124d9e8-6266-4bcf-8035-37a02ba75c69 | 110e8400-e29b-11d4-a716-446655440000 | 1422219048 | 1 | ACCEPTED | <null> | <null> | When the pricer sent a price defined by: | MESSAGE_ID | REQUEST_ID | TIMESTAMP | STATUS_CODE | STATUS_TEXT | TEXT | PRICE | | ac56a704-260b-45f5-85ac-e1b451bb79bc | 110e8400-e29b-11d4-a716-446655440000 | 1422219048 | 1 | UPDATED | <null> | 555 | Then the customer should receive the price defined by: | MESSAGE_ID | REQUEST_ID | TIMESTAMP | STATUS_CODE | STATUS_TEXT | TEXT | PRICE | | ac56a704-260b-45f5-85ac-e1b451bb79bc | 110e8400-e29b-11d4-a716-446655440000 | 1422219048 | 1 | UPDATED | <null> | 555 |
  16. Feature: Price request mapping for the pricer Scenario: A customer

    price request is converted in order to be understood by the pricer Given a request for a price from the customer containing the following information : | Request Id | 1 | | Customer Id | 42 | | Product Type | Actions | When the request is converted Then the pricer request should contains the following information : | Request Id | 1 | | Customer Id | 42 | | Product Type | A |
  17. Celui qui met du concombre à toutes les sauces ou

    lorsqu’on oublie que tout ne se prête pas au BDD
  18. Feature: System restart behavior Scenario: As the system, I want

    all my transactions to be closed when I restart Given a system with 8 opened transactions When the system restarts Then no transactions should be opened
  19. Converser, communiquer, collaborer ! Faire émerger l’ubiquitous language Mieux se

    comprendre et lever les ambiguïtés Faire attention à la rédaction des scénarios lisible compréhensible déclaratif Ne pas négliger le code des fixtures même standards que le code de production facile à maintenir