zoukankan      html  css  js  c++  java
  • Cucumber 场景大纲 Scenario Outlines

    引用链接:https://github.com/cucumber/cucumber/wiki/Scenario-Outlines

      1.  script/cucumber --i18n zh-CN  
      2.       | feature          | "功能"       |  
      3.       | background       | "背景"       |  
      4.       | scenario         | "场景"       |  
      5.       | scenario_outline | "场景大纲"     |  
      6.       | examples         | "例子"       |  
      7.       | given            | "* ""假如" |  
      8.       | when             | "* ""当"  |  
      9.       | then             | "* ""那么" |  
      10.       | and              | "* ""而且" |  
      11.       | but              | "* ""但是" |  
      12.       | given (code)     | "假如"       |  
      13.       | when (code)      | "当"        |  
      14.       | then (code)      | "那么"       |  
      15.       | and (code)       | "而且"       |  
      16.       | but (code)       | "但是"       | 

    Copying and pasting scenarios to use different values quickly becomes tedious and repetitive:

    Scenario: eat 5 out of 12
      Given there are 12 cucumbers
    When I eat 5 cucumbers
    Then I should have 7 cucumbers
    
    Scenario: eat 5 out of 20
      Given there are 20 cucumbers
    When I eat 5 cucumbers
    Then I should have 15 cucumbers
    

    Scenario outlines allow us to more concisely express these examples through the use of a template with placeholders, using Scenario Outline, Examples with tables and < > delimited parameters:

    Scenario Outline: eating
      Given there are <start> cucumbers
    When I eat <eat> cucumbers
    Then I should have <left> cucumbers
    
    Examples:
        | start | eat | left |
        |  12   |  5  |  7   |
        |  20   |  5  |  15  |
    

    The Scenario Outline steps provide a template which is never directly run. A Scenario Outline is run once for each row in the Examples section beneath it (not counting the first row).

    The way this works is via placeholders. Placeholders must be contained within < > in the Scenario Outline's steps. For example:

    Given <I'm a placeholder and I'm ok>
    

    The placeholders indicate that when the Examples row is run they should be substituted with real values from the Examples table. If a placeholder name is the same as a column title in the Examples table then this is the value that will replace it.

    You can also use placeholders in Multiline Step Arguments.

    IMPORTANT: Your step definitions will never have to match a placeholder. They will need to match the values that will replace the placeholder

    So when running the first row of our example:

    Examples:
      | start | eat | left |
      |  12   |  5  |  7   |
    

    The scenario that is actually run is:

    Scenario: controlling order
      Given there are 12 cucumbers      # <start> replaced with 12
    When I eat 5 cucumbers            # <eat> replaced with 5
    Then I should have 7 cucumbers    # <left> replaced with 7

    ----------------------------------------------------------------------------------------

    场景大纲:输入产品ID并验证
      假如 打开首页
      而且 输入<<ProdID>> #双尖括号
     
    例子:产品ID                  #"产品ID"是自定义的
        |ProdID|
        |111111|
        |222222|
        |333333|
        |444444|
  • 相关阅读:
    图像通道的分离与合并
    frame表单嵌套的定位
    windows10(家庭版)+ laradock 安装踩坑记一记
    Laradock + tp5 + nginx 配置虚拟机域名始终跳转首页/502报错
    php私有组件以及创建自己的composer私有组件(packagist+git+composer)
    申请一个美国paypal账户
    php执行shell脚本
    Linux修复日志
    php7 安装redis拓展
    vim编辑器-删除命令
  • 原文地址:https://www.cnblogs.com/dami520/p/3243522.html
Copyright © 2011-2022 走看看