使用命令行命令

时间:2017-05-26 00:10:34

标签: protractor bdd webdriver-io cucumberjs

我想使用量角器从场景大纲中执行单个测试用例。例如,在下面的场景大纲中,如果我想单独执行测试用例TCID0002,我如何使用量角器运行测试用例TCID0002?

@shopping
Scenario Outline: Test
    Given the user navigates to xxx.com
    When the user searches for <product>
    Then the current page is shopping cart page
    Examples:
    |TCID    |  product|
    |TCID0001|soap     |
    |TCID0002|watch    |
    |TCID0003|lipstick |

现在运行所有测试用例我使用

protractor Config.js --cucumberOpts.tags="@shopping" 

是否有任何命令在场景大纲中执行单个测试用例?

2 个答案:

答案 0 :(得分:0)

您可以在示例表上使用标记并将其拆分为两个表。然后在配置文件中为@runone提供cucumberOpts代码标记选项。

@runall
Examples:
    |TCID    |  product|
    |TCID0001|soap     |
    |TCID0002|watch    |
    |TCID0003|lipstick |

@runone
Examples:
    |TCID    |  product|
    |TCID0002|watch    |

答案 1 :(得分:0)

在我的团队成员的帮助下找到了在黄瓜中执行单个测试用例的解决方案。

要运行单个测试用例,请按照以下2个步骤进行操作

第1步

在方案标题中保留 TCID ,如下所示

Scenario Outline: <TCID> test case to validate search
    Given the user navigates to xxx.com
    When the user searches for <product>
    Then the current page is search result page
    Examples:
    |TCID    |  product|
    |TCID0001|soap     |
    |TCID0002|watch    |
    |TCID0003|lipstick |

第2步

在命令中使用cucumberOpts.name。 'cucumberOpts.name'将过滤场景标题中包含给定字符串的场景。 --cucumberOpts.name =“WAGCAR0002”将单独过滤WAGCAR0002场景。

<强>命令

以下命令将执行测试用例'WAGCAR0002'

protractor Config/wagConfig.js --cucumberOpts.name="WAGCAR0002"
相关问题