请参阅“方案大纲"示例中的已定义变量 [英] Refer defined variable in Scenario outline example
问题描述
Feature: Test Type
Background:
* url host
* def name = 'test_name'
* def label = name
Scenario Outline: Test 2
Given url homeLinks.groupTypesUrl
And headers { tenant: #(tenantId), Authorization: #(authToken) }
* def name = <name>
* def description = <description>
* def label = <label>
* json data = read('path/to/file/create_group_type_request.json')
And request data
When method POST
Then status 400
Examples:
| name | label | description |
| '\u0000' | 'label' | 'description' |
| #(name) | '\u0000'| 'description' |
我需要引用在示例映射中定义的全局名称.如何获得参考?
I need to refer global name defined inside examples map. How to get that reference?
当我尝试喜欢上面的代码时,遇到Java语言评估错误.
Getting Javascript evalution error when I tried to like above piece of code.
推荐答案
是的,Examples
做不支持JS eval和变量.使用 table
表单,并用call
循环到另一个功能: https://github.com/intuit/karate#calling-other-feature-文件
Yes, Examples
do not support JS eval and variables. Use the table
form and loop over it with a call
to a second feature: https://github.com/intuit/karate#calling-other-feature-files
或者您可以通过在后台初始化table
来尝试使用动态Scenario Outline
:
Or you can try to use a dynamic Scenario Outline
by initializing the table
in the background: https://github.com/intuit/karate#dynamic-scenario-outline
这篇关于请参阅“方案大纲"示例中的已定义变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!