如何从 Cucumber Scenario 传递字符串列表 [英] How to pass List of strings from Cucumber Scenario

查看:18
本文介绍了如何从 Cucumber Scenario 传递字符串列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从黄瓜场景中传递字符串列表,如下所示

I need to pass the List of strings from cucumber scenario which works fine as below

Scenario Outline: Verify some scenario 
Given something
When user do something 
Then user should have some "<data>" 
Examples: Some example
|data|
|Test1, Test2, Test3, Test4|

在步骤定义中,我使用 List 来检索某个变量的值.但是当数据变量的值之一包含逗号(,)时,例如Tes,t4 它变得复杂,因为它将Tes"和t4"视为两个不同的值

In the step definition I use List to retrieve the values of something variable. But when one of the value of data variable contains comma(,) e.g. Tes,t4 it becomes complex,since it considers "Tes" and "t4" as two different values

 Examples: Some example
 |something|
 |Test1, Test2, Test3, Tes,t4|  

那么有没有我可以使用的转义字符,或者有没有其他方法可以处理这种情况

So is there any escape character that i can use or is there is there any other way to handle this situation

推荐答案

找到了一个简单的方法.请参阅以下步骤.

Found an easy way. Please see the below steps.

  • 这是我的功能文件.

  • Here is my feature file.

这里是映射特征步骤的对应代码.

Here is the corresponding code to map feature step with code.

哦,是的.结果很重要.您可以看到调试视图.

Oh yes. Result is important. You can see the debug view.

这篇关于如何从 Cucumber Scenario 传递字符串列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆