Reputation: 619
Taurus allows me combine scenarios like this
scenarios:
create-bob-account:
requests:
- url: http://example.com/account/create
method: POST
body:
account_owner: bob
account_number: 123
create-lisa-account:
requests:
- url: http://example.com/account/create
method: POST
body:
account_owner: lisa
account_number: 321
account-transfer:
requests:
- include-scenario: create-bob-account
- include-scenario: create-bob-account
- url: http://example.com/transfer
method: POST
body:
account_number_from: 123
account_number_to: 321
...
In this example i have duplicate code that creates info about accout bob and lisa. Can i parametrize an create-account scenario? I.e. create script
scenarios:
create-account:
requests:
- url: http://example.com/account/create
method: POST
body:
account_owner: ${owner}
account_number: ${number}
and call it with different variables, something like this
scenarios:
account-transfer:
requests:
- include-scenario:
arugment: bob, 123
create-account
- include-scenario:
arugment: lisa, 321
create-account
- url: http://example.com/transfer
Maybe there is some way to implement this functionality? The basic idea is to identify scripts that are independent of specific variables and reuse them in various scripts with the variables that are needed.
Thanks!
Upvotes: 0
Views: 1155
Reputation: 168072
How about CSV Data Set Config? This way you can put your account names and IDs into a CSV file and include the request block to read these name/id combination from the CSV file, the relevant Taurus directives are data-sources
and include-scenarios
Example YAML config:
execution:
- scenario: account-transfer
scenarios:
account-create:
data-sources:
- details.csv
requests:
- url: http://example.com/account/create
method: POST
body:
account_owner: ${account_owner}
account_number: ${account_number}
account-transfer:
requests:
- include-scenario: account-create
- include-scenario: account-create
- url: http://example.com/transfer
method: POST
body:
account_number_from: 123
account_number_to: 321
Upvotes: 1