ATDD It’s Not Just About Writing Tests...Imperative Declarative Given I am on the home page When I...

41
ATDD It’s Not Just About Writing Tests Debbie Evans Pete Thomas

Transcript of ATDD It’s Not Just About Writing Tests...Imperative Declarative Given I am on the home page When I...

ATDD It’s Not Just About Writing Tests

Debbie Evans Pete Thomas

Who are you?

The Start

Requirement definition

Feature testing

Continuous testing

Traceability

Regression testing

Documentation

SBE

ATDD

Where we were…

Let’s automate stuff!

Users

Technology

Business Analyst

This looks like it’s for tech, what about everyone else?

Why are we doing this?

Reset

Who are the stakeholders in the process?

What do you want me to build?

Technology

How do I know if it’s right?

Users

Can you tell me what the system

does? How do I know you built what we agreed?

How do I know you haven't broken anything?

Compliance & Audit

Did you build what was asked?

Did someone authorised to do so, say it was

correct?

How do I know you haven't broken anything? How did they

know it was correct?

Change

https://cucumber.pro/blog/2014/03/03/the-worlds-most-misunderstood-collaboration-tool.html

http://blog.mattwynne.net/2013/01/17/the-problem-with-solutions/

http://www.slideshare.net/lunivore/behavior-driven-development-11754474

S B E a s a p r o c e s s o v e r S B E a s a d e l i v e r a b l e

W r i t i n g a d o c u m e n t o v e r W r i t i n g a t e s t s c r i p t

Optimised for readability over Optimised for execution

O n e b u s i n e s s r u l e p e r t e s t o v e r F e w e r t e s t s

U n d e r s t a n d i n g f o r a l l o v e r E x p e r t s o n l y

T r u s t t h e c l a r i t y o v e r D i s b e l i e v i n g r e s u l t s

E a s y t o f i n d o v e r H i d d e n i n t h e b u i l d

Consistent quality Living documentation Traceability

Tools?

Test better together

SBE + Social Testing = Collaborative Learning

Things to look out for….

Imperative vs Declarative

Imperative Declarative

Given I am on the home page When I enter 'Peter' into the first name text box And enter 'Thomas' into the last name text box And click on the date of birth calendar drop down And click on 1972 in the year box And click on 'January' in the month box And click on '1' in the day box And click on 'create user' button Then a pop up showing 'User Created' is displayed

Imperative Declarative

Imperative Declarative

Scenario Styles

Scenario:  1)  A  user  cannot  authorise  a  break  item  last  modified  by  themselves  

               Given  the  following  break  items  Awai=ng  Authorisa=on                      |Break  ID          |  Last  Modified  By      |                      |  1        |  Current  User                    |                      |2      |  Not  Current  User    |                  And  the  user  is  Current  User                  When  the  break  items  are  selected  for  authorisa=on                  Then  the  following  break  Items  will  be  eligible  for  authorisa=on                          |  Break  ID  |                          |  2                            |                  And  the  User  will  be  informed  that  some  selected  items  were  not  eligible  

Scenario  using  tables  

Scenario:  The  user  can  cancel  the  crea=on  of  a  break  Item  

               Given  the  reconcilia=on  detail  entry  is  complete                  And  the  user  cancels  the  Break  Item  crea=on                  Then  there  is  no  new  break  item  in  the  system  

Scenario  Simple  

Scenario  Outline:  The  ability  to  enter  a  break  is  restricted  by  a  users  role  

               Given  the  user  has  the  role    of  <Role>                  Then  the  user  can  <Enter  a  Break>            Examples:                  |  Role                            |  Enter  a  Break  |                  |  User                            |  Yes                                      |                  |  Administrator      |  Yes                                      |                  |  Manager                      |  No                                        |                  |  Enricher                        |  No                                        |                  |  Support                          |  No                                        |  

Scenario  Outline  

So What?

Scenario:  The  system  closes  while  excluding  items  

So  What?  

Scenario:  The  system  closes  while  excluding  items    

               Given  the  system  is  open  for  the  current  day  

               And  a  break  item  is  selected  for  exclusion  

               When  the  system  then  closes  for  the  current  day  

               And  the  user  confirms  the  exclusion  

               Then  the  error  message  ‘The  system  is  closed  for  workflow’  is  displayed  

         And  the  item  is  not  Excluded  

What  would  a  good  scenario  descrip=on  be?  

Scenario:  An  item  excluded  aVer  the  system  close  will  not  be  processed    

               Given  the  system  is  open  for  the  current  day  

               And  a  break  item  is  selected  for  exclusion  

               When  the  system  then  closes  for  the  current  day  

               And  the  user  confirms  the  exclusion  

               Then  the  error  message  ‘The  system  is  closed  for  workflow’  is  displayed  

           And  the  item  is  not  Excluded  

Reverse Engineering

Given  an  account  with  cut-­‐off  date  of  15-­‐Jan-­‐2025,  First  Ac=vity  Date  15-­‐Jan-­‐2025  and  a  posi=on  of  10  

When  an  Adjustment  of  1000  is  received  with  Effec=ve  Date  of  <Effec=ve  Date>  and  Actual  Date  of  16-­‐Jan-­‐2025  

Then  the  resul=ng  Posi=on  is  <Expected  Posi=on>  

   Examples:          |  Effec=ve  Date          |  Expected  Posi=on  |          |  14-­‐Jan-­‐2025    |  1010                                            |          |  15-­‐Jan-­‐2025    |  10                                                    |          |  16-­‐Jan-­‐2025    |  10                                                    |  

Can  you  determine  what  the  scenario  descrip=on  should  be?  

Scenario  Outline:  An  Adjustment  is  applied  if  its  Effec=ve  Date  is  before  Cut-­‐Off  Date  

Given  an  account  with  cut-­‐off  date  of  15-­‐Jan-­‐2025,  First  Ac=vity  Date  15-­‐Jan-­‐2025  and  a  posi=on  of  10  

When  an  Adjustment  of  1000  is  received  with  Effec=ve  Date  of  <Effec=ve  Date>  and  Actual  Date  of  16-­‐Jan-­‐2025  

Then  the  resul=ng  Posi=on  is  <Expected  Posi=on>  

   Examples:          |  Effec=ve  Date        |  Expected  Posi=on  |          |  14-­‐Jan-­‐2025    |  1010                                            |          |  15-­‐Jan-­‐2025    |  10                                                    |          |  16-­‐Jan-­‐2025    |  10                                                    |  

How  can  you  simplify  the  example?  

Scenario  Outline:  An  Adjustment  is  applied  if  its  Effec=ve  Date  is  before  Cut-­‐Off  Date  

Given  an  account  with  cut-­‐off  date  of  15-­‐Jan-­‐2025  

When  an  Adjustment  is  received  with  Effec=ve  Date  of  <Effec=ve  Date>    

Then  the  Adjustment  is  <Applied>  

   Examples:          |  Effec=ve  Date                          |  Applied  |          |  14-­‐Jan-­‐2025    |  Y                          |          |  15-­‐Jan-­‐2025    |  N                        |  

Exercises Bad Smells

•  Ambiguity in requirements •  Missing scenarios •  Users asking how things work •  Asking for proof of testing success •  Inaccessible test results/documentation •  Duplicated/similar scenarios •  Unintelligible scenarios

Top Tips

•  Aim for declarative scenarios •  Describe behaviour •  Target audience is a competent novice •  Should be able to reverse engineer rules from scenarios •  Write consistently in the business domain •  Avoid unnecessary detail •  One rule per scenario •  Optimise for readability

Keep  the  tables  as  simple  as  possible  and  avoid  describing  mul=ple  rules  in  one  spec.  

Feature: Automated Trade Settlement

As a Settlements Operations User I want settlements from agent banks to be processed So that Trades reflect Settlement properly

Scenario: Autocash Settlement of a Free of Payment Trade on Value Date

Given a trade of <settlement type> And cash open quantity of <cash open quantity> And value date of <value date> When the business date is 18/07/2013 Then the cash open quantity is updated to <updated cash open quantity>

Examples:

Settlement Type Cash Open Quantity Value Date Updated Cash Open Quantity Free of Payment 10,000 18/07/2013 0 Free of Payment 11,000 19/07/2013 11,000 Delivery versus Payment 12,000 18/07/2013 12,000

Feature: Automated Trade Settlement

As a Settlements Operations User I want settlements from agent banks to be processed So that Trades reflect Settlement properly

Scenario: Autocash Settlement of a Free of Payment Trade on Value Date

Given a Free Of Payment Trade When the value date is today Then the cash fully settles

Given a Free Of Payment Trade When the value date is in the future Then the cash remains open

Given a Delivery versus Payment Trade When the value date is today Then the cash remains open

It’s not just about testing!