A handshake
Run a process with multiple actors and actions.
In the previous tutorial, we created and tested our first scenario. In that scenario, we didn't define any actors. In this tutorial, we explicitly define multiple actors to participate in the process.
Defining actors
Each actor plays a specific role in the scenario. We'll tie the actor to a particular user (or team) when creating the process. We define two actors for the handshake 'initiator' and 'recipient' and give each actor a title.
Create file handshake.yaml (or handshake.json) in the scenarios directory.
actors:
initiator:
title: Initiator
recipient:
title: Recipient
states:
initial:
on: complete
goto: (success){
"actors": {
"initiator": {
"title": "Initiator"
},
"recipient": {
"title": "Recipient"
}
},
"states": {
"initial": {
"on": "complete",
"goto": "(success)"
}
}
}Greeting each other
We want the two actors to interact in the form of a simple greeting:
Initiator: Hi, how are you? Recipient: Fine. How about you? Initiator: Fine
The initiator will still complete the process, but from the initial state, it will first do a greeting, expecting a reply. We'll add these 2 states where these can be performed. First, the initiator waits on the recipient and then visa versa.
We use the by property to specify which actor can perform the action in that state.
Scenario
We see that we transition from the "initial" state to "wait_on_recipient", then wait on "initiator" and finally to successful completion of the process.
Test case
Create file handshake.feature in the features directory.
Choose to ignore
Let's give the recipient a choice to either reply or ignore the greeting. If he chooses to ignore the greeting the process will have failed.
Scenario
For the "wait_on_recipient" state we define two transitions. Both can only be performed by the "recipient" actor.
Test case
We can add a new Scenario section in our test file to test the path in the process where the recipient "Jane" ignores the greeting.
You can have multiple Scenario sections. The Background is run before each Scenario.
Last updated
Was this helpful?