传递变量数组中specflow [英] Passing arrays of variable in specflow

查看:260
本文介绍了传递变量数组中specflow的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法来传递参数数组,而不是逐个传递每个参数。

Is there a way to pass an array of parameters instead of passing each parameters individually.

有关例如我有以下情形

When i login to a site
then <firstname>, <lastname>, <middleName>, <Desingation>, <Street>, <Apartmentno> are valid

该列表可以在上面去。
相反,我可以通过所有上述变量在数组中。

The list can go on above. Instead can i pass all the above variables in an array.

推荐答案

您可以通过一个逗号分隔的字符串,然后把它转换成一个列表:

You can pass a comma separated string and then transform it into a list:

When i login to a site
then 'Joe,Bloggs,Peter,Mr,Some street,15' are valid

[Then("'(.*)' are valid")]
public void ValuesAreValid(List<String> values)
{
}

[StepArgumentTransformation]
public List<String> TransformToListOfString(string commaSeparatedList)
{
    return commaSeparatedList.Split(",").ToList();
}

如果您希望值来自例子,你可以这样做,而不是:

if you want the values to come from examples then you could do this instead:

When I login to a site
then '<values>' are valid
Examples
| values                            |
| Joe,Bloggs,Peter,Mr,Some street,15|
| Joe,Bloggs,Peter,Mr,Some street,16,SomethingElse,Blah|

如果你想使用一个表,那么你可以这样做,而不是:

If you want to use a table then you could do this instead:

When I login to a site
then the following values are valid
    | FirstName | LastName | MiddleName | Greeting| Etc    | Etc     |
    | Joe       | Bloggs   | Peter      | Mr      | you get| The Idea|

(你可以省略标题,如果你想,只是使用行值我认为)

(you could omit the headers if you want and just use the row values I think)

这个选项意味着你不能使用的例子,但。

This option means you can't use examples though.

这篇关于传递变量数组中specflow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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