【问题标题】:How to write Scenario Outlines with dinamic values ​?如何用动态值编写场景大纲?
【发布时间】:2021-09-01 15:45:49
【问题描述】:

enter image description here例如:

Scenario Outline:
Given the user is logged into Home Operations
When searching for "<status>"
Then the "<result>" and "<total>" are presented

Examples:
| status  |
|approved |
|created  |
|rejected |
|confirmed|

resulttotal 是动态值。请问如何解决这个问题?

***Result*** is the total by status type.
***Total*** is the sum of the statuses.

【问题讨论】:

    标签: ruby cucumber bdd scenarios


    【解决方案1】:

    当您说动态值时,我认为您是在运行时得到的,或者换句话说,在您运行 BDD 之前您不会知道这些值。如果是这种情况,您需要重新考虑如何编写 BDD。对于每一个价值,都应该有一个商定的结果。例如,如果状态被批准,那么对于结果和总数,您应该有一个预先定义/同意的值。

    例如,您上面的 BDD 可以重写为

    Scenario Outline: 
    Given the user is logged into Home Operations 
    When searching for "<status>" 
    Then the "<result>" and "<total>" are presented
    
    Examples:
    | status  | result  |total|
    |approved | success | $20 |
    |created  | pending | $20 |
    |rejected | failed  | $0  |
    |confirmed| success | $20 |
    

    您不应该在测试中期待动态值。您的测试数据的设置方式应始终让您期待预期的结果。

    【讨论】:

    • 谢谢杰罗姆!!...你的解释很好。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-11
    相关资源
    最近更新 更多