【问题标题】:Using data tables inside example tables in cucumber在黄瓜的示例表中使用数据表
【发布时间】:2020-08-29 17:58:02
【问题描述】:

我正在使用 BDD Cucumber 处理自动化测试用例。在我的测试用例中,我使用的场景大纲如下:

Scenario Outline: My test case
Given: My data is ready
When : My data is <r1>, <r2>, <r3>
Then: My data is <valid>

Examples:
|r1| r2|r3| valid |
|1 | 2 | 3| valid |

现在我想在“时间”中添加许多数据条目,这会使“时间”变得很长。是否有可能,我可以在此示例表中使用数据表,以便传递我的数据并且语句不会变得太长?我在官方文档上搜索了这个,但没有得到任何关于在示例表中使用数据表的参考。

【问题讨论】:

    标签: cucumber bdd cucumber-jvm


    【解决方案1】:

    是的,您应该可以将示例标记放在数据表单元格中:

    Scenario Outline: My test case
        Given: My data is ready
        When : My data is:
            | Field | Value |
            | R1    | <r1>  |
            | R2    | <r2>  |
            | R3    | <r3>  |
    Then: My data is <valid>
    
    Examples:
        | r1 | r2 | r3 | valid |
        | 1  | 2  | 3  | valid |
    

    【讨论】:

    • 我正在使用相同的方法。但是在步骤定义中,一切都以字符串的形式出现。我希望列 r1, r1, r3 是一个整数并且作为字符串的有效列。有可能吗?
    • @RAMESKUMAR:是的,这是可能的。请通过minimal reproducible example 发布问题。我经常在这里浏览specflow 标签,所以我可能很快就会看到它。
    • 我看到这个问题被标记为cucumber,这也是我经常使用的另一个标记。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-03
    • 1970-01-01
    • 2011-07-27
    • 2013-04-08
    • 2018-09-23
    • 1970-01-01
    相关资源
    最近更新 更多