【问题标题】:Splitting examples in Given and Then for SpecFlow Scenario Outline拆分 Given 和 Then 中的示例用于 SpecFlow Scenario Outline
【发布时间】:2016-08-11 10:05:29
【问题描述】:

我正在编写一个具有多个输入和输出参数(每个大约 4-5 个)的 specflow 场景。使用场景大纲时,我需要编写一个宽表,在同一行中提供输入和输出列。有什么方法可以为步骤定义单独指定示例?这是为了提高可读性。

当前状态

Given - State of the data
When I trigger action with parameters <input1> and <input2> and ...
Then my output should contain <output1> and <output2> ...

Examples:
| input1 | input2 |... | output1 | output2 |...

我可以这样做吗?

Given - State of the data
When I trigger action with parameters <input1> and <input2> and ...
       Examples of input
Then my output should contain <output1> and <output2> ...
        Examples of output

【问题讨论】:

    标签: bdd specflow gherkin


    【解决方案1】:

    不,不幸的是,这(或类似的事情)是不可能的。 您可以使您的输入和输出更加抽象,并可能合并几列。示例:而不是国家 |邮政编码 |城市 |街道 |房子 |名字 |姓氏 |等你应该有|地址 |职位名称 |地址为“欧盟”、“美国,缺少邮政编码”、“总部”等值。

    【讨论】:

    • 谢谢!看来我现在必须忍受它了。
    【解决方案2】:

    场景大纲不能有多个示例表,但可以传入常规场景的数据表。

    数据表只能由使用它的步骤访问,但是您可以将其保存在场景上下文中以供后续步骤使用。

    如果您的场景很复杂并且跨越多行,不确定这是否适合您,但我想我会提到它。

    Scenario: Checking outputs for inputs
    Given - State of the data
    When I trigger action with the following parameters  
    input1 | input2 | input3 |
    data   | data   | data   |
    
    Then my output should contain the following outputs
    output1 | output2  | output3 |
    data    | data     | data    |
    

    【讨论】:

    • 没有。我想到了这一点,但我的输入很复杂,不能像你提到的那样放在列。
    猜你喜欢
    • 2018-01-30
    • 1970-01-01
    • 1970-01-01
    • 2021-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-18
    相关资源
    最近更新 更多