Awaiting state - One scenario with multiple When/Then versus Two scenarios and shared context

48 Views Asked by At

We are starting SpecFlow implementation and we are trying to find the best practice regarding a feature which required an awaiting state during the flow.

Should we use one scenario with several When/Then to test the Feature? Or should we use two scenarios with a shared context?

Let's take the following fictive example: A contract creation following a product sale. Steps from the contract management products view:

  1. (When) An event is received with contract creation details
  2. (Then) System A create a process for the new contract
  3. (And) System A asks for the Client information to System B (Awaiting state occurs there)
  4. (When) System A receives Client information
  5. (Then) System A packages all contract-related information and publish them to other system

Implementation above is just to give you an idea of our problem.

Should we go with a big sceario like this:

  • When An event is received with contract creation details
  • Then System A create a process for the new contract
  • And System A asks for the Client information to System B
  • When System A receives Client information from System B
  • Then System A packages all contract-related information and publish them to other system

Or with two distinct scenarios like this:

1 - Acknowledged contract creation

  • When An event is received with contract creation details
  • Then System A create a process for the new contract
  • And System A asks for the Client information to System B

2 - Contract creation publication

  • When System A receives Client information from System B
  • Then System A packages all contract-related information and publish them to other system

We are not sure what is the best practice to follow in this particular case.

Find best practice for SpecFlow features required awaiting steps and multiple systems interractions

1

There are 1 best solutions below

0
M.P. Korstanje On

It seems to me the first two parts are setup, the second part the action, and the last part the effect. So:


    Given An event is received with contract creation details
    And System A create a process for the new contract
    When System A asks for the Client informations to System B
    Then System A receives Client informations from System B
    And System A packages all contract-related informations and publish them to other system

Or if everything is triggered by the first step, then it would be a single When followed by a Then and a few And after that.


    When An event is received with contract creation details
    Then System A create a process for the new contract
    And System A asks for the Client informations to System B
    And System A receives Client informations from System B
    And System A packages all contract-related informations and publish them to other system

You may at that point consider using the * keyword. If specflow supports it.