如何在空手道DSL中的方案大纲中传递动态变量 [英] How to pass dynamic variable in Scenario outline in Karate DSL
本文介绍了如何在空手道DSL中的方案大纲中传递动态变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到一种情况,我需要在空手道中传递其他各种Date类型变量.为此,我创建了一个JAVA方法并在功能文件中调用它,如下所示.
I have a situation where I need to pass a different variety of Date type variables in Karate. For this, I created a JAVA method and calling it in a feature file as shown below.
我了解到它的黄瓜限制不能支持方案大纲"中的动态变量.我还阅读了 https://github.com/intuit/karate#the-karate-way但以某种方式,我不知道如何解决以下情况.
I read that its cucumber limitation which can not support dynamic variables in Scenario Outline. I also read https://github.com/intuit/karate#the-karate-way but somehow, I am not getting any idea how to solve the below situation.
Scenario Outline: test scenario outline
* def testData = Java.type('zoomintegration.utils.DataGenerator')
* def meetDate = testData.futureDate(2)
* def jsonPayLoad =
"""
{
"meetingSource": <meetingSource>,
"hostId": <host>,
"topic": <topic>,
"agenda": <topic>,
"startDateTime": <meetingDate>",
"timeZone": "Asia/Calcutta",
"duration": <duration>
}
"""
* print jsonPayLoad
Examples:
|meetingSource|host|topic|duration|meetingDate|
|ZOOM | abc |Quarter meeting|30|0|
|SKYPE | abc |Quarter meeting|30|'1980-08-12'|
|MS | abc |Quarter meeting|30|'2030-12-12'|
推荐答案
以下代码对我有用:
Scenario Outline: test scenario outline
* def testData = Java.type('zoomintegration.utils.DataGenerator')
* def meetDate = testData.futureDate(<meetingDate>)
* def jsonPayLoad =
"""
{
"meetingSource": <meetingSource>,
"hostId": <host>,
"topic": <topic>,
"agenda": <topic>,
"startDateTime": #(meetDate),
"timeZone": "Asia/Calcutta",
"duration": <duration>
}
"""
* print jsonPayLoad
Examples:
| meetingSource | host | topic | duration | meetingDate |
| ZOOM | abc | Quarter meeting | 30 | 1 |
| SKYPE | abc | Quarter meeting | 30 | 2 |
| MS | abc | Quarter meeting | 30 | 3 |
这篇关于如何在空手道DSL中的方案大纲中传递动态变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文