首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Specflow中将多个数据作为输入输入到同一个特征文件中

如何在Specflow中将多个数据作为输入输入到同一个特征文件中
EN

Stack Overflow用户
提问于 2021-01-11 21:21:31
回答 1查看 1.2K关注 0票数 0

我在应用程序中有一个表单,需要填充数据,比如创建一个雇员。需要填写详细信息,如员工代码、姓名、地址、银行详细信息。我创建了一个包含4个场景的功能文件:

details

  • Employee

  • 雇员个人地址

  • Bank Details

  • Etc..

当字段相同时,如何传递5-10名员工的数据?问题是在创建时需要填充15-20个字段。我尝试使用示例关键字,行长度增加,这使得滚动和搜索变得困难。我还有别的方法可以给他们投入吗?我怀疑我们能否为每个场景提供4个示例文件。这是真的吗?

请帮忙找个更好的办法。

下面是一个屏幕截图,展示了我刚才提到的示例文本:

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-01-13 14:50:35

不要将所有字段都包含在示例表中,而是关注与当前场景相关的字段。

例如,有关个人详细信息的场景如下所示:

代码语言:javascript
复制
Scenario Outline: Entering personal details when creating an employee
    Given the user is creating a new employee
    When the user enters the employee personal details:
        | Field         | Value           |
        | First Name    | <First Name>    |
        | Last Name     | <Last Name>     |
        | Date of Birth | <Date of Birth> |
    And the user enters the employee address
    And the user enters the employee banking details
    And the user saves the new employee
    Then ...

    Examples:
        | First Name | Last Name | Date of Birth |
        | ...        | ...       | ...           |
        | ...        | ...       | ...           |
        | ...        | ...       | ...           |

步骤When the user enters the employee personal details:包含与输入个人详细信息相关的字段。有关输入员工地址和银行详细信息的其他步骤可以使用通用数据,只要输入的数据满足业务规则。

同样,想象一下输入地址的场景:

代码语言:javascript
复制
Scenario Outline: Entering new employee address
    Given the user is creating a new employee
    When the user enters the personal details for the new employee
    And the user enters the employee address:
        | Field       | Value         |
        | Line 1      | <Line 1>      |
        | Line 2      | <Line 2>      |
        | City        | <City>        |
        | State       | <State>       |
        | Postal Code | <Postal Code> |
    And the user enters the employee banking details
    And the user saves the new employee
    Then ...

    Examples:
        | Line 1 | Line 2 | City | State | Postal Code |
        | ...    | ...    | ...  | ...   | ...         |
        | ...    | ...    | ...  | ...   | ...         |
        | ...    | ...    | ...  | ...   | ...         |

这使得每个场景的示例表都更小,更易于阅读,但也为您提供了大量的数据输入灵活性。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65674703

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档