金牛座。重用具有不同变量的常见场景
Taurus. Reusing common scenario with different variables
金牛座允许我这样组合场景
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
...
在这个例子中,我有创建关于 accout bob 和 lisa 信息的重复代码。我可以参数化 create-account 场景吗? IE。创建脚本
scenarios:
create-account:
requests:
- url: http://example.com/account/create
method: POST
body:
account_owner: ${owner}
account_number: ${number}
并用不同的变量调用它,像这样
scenarios:
account-transfer:
requests:
- include-scenario:
arugment: bob, 123
create-account
- include-scenario:
arugment: lisa, 321
create-account
- url: http://example.com/transfer
也许有什么方法可以实现这个功能?
基本思想是识别独立于特定变量的脚本,并在具有所需变量的各种脚本中重用它们。
谢谢!
怎么样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
YAML 配置示例:
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
金牛座允许我这样组合场景
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
...
在这个例子中,我有创建关于 accout bob 和 lisa 信息的重复代码。我可以参数化 create-account 场景吗? IE。创建脚本
scenarios:
create-account:
requests:
- url: http://example.com/account/create
method: POST
body:
account_owner: ${owner}
account_number: ${number}
并用不同的变量调用它,像这样
scenarios:
account-transfer:
requests:
- include-scenario:
arugment: bob, 123
create-account
- include-scenario:
arugment: lisa, 321
create-account
- url: http://example.com/transfer
也许有什么方法可以实现这个功能? 基本思想是识别独立于特定变量的脚本,并在具有所需变量的各种脚本中重用它们。
谢谢!
怎么样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
YAML 配置示例:
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