【问题标题】:How to run selected feature files/scenarios in cypress cucumber and skip others如何在 cypress cucumber 中运行选定的功能文件/场景并跳过其他文件
【发布时间】:2020-03-11 07:59:42
【问题描述】:

我尝试了几个命令,但似乎没有任何效果。要么全部转义,要么不运行。

@TestFeature
Feature: Test Feature

    Testing sample feature

    Background: Logging in
    @manual
    Scenario: A
        Given
    Scenario Outline: B

我想运行Test Feature 并跳过标记为manual 的场景。我试过了-

npx cypress run --env TAGS=@TestFeature and not @manual --browser chrome

但它不起作用。也尝试了类似的组合,但没有任何效果。

【问题讨论】:

    标签: cucumber cypress


    【解决方案1】:

    您可以在功能文件中使用 @tags 并让赛普拉斯仅运行选定的测试。您需要小心转义引号。以下对我有用(运行带有@accessibility 标签的测试):

    package.json

    "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build",
        "cypress:open": "cypress open",
        "cypress:run": "cypress run",
        "test:accessibility": "./node_modules/.bin/cypress-tags run -e TAGS=\"@accessibility\"",
        "test": "cypress run --spec \"**/*.feature\"",
        "eject": "react-scripts eject"
      },
    

    然后在命令提示符下:

    cypress-tags run -e TAGS="@accessibility"
    

    【讨论】:

    • 当我使用标签 @smoke 运行一个场景时,它可以工作,但同时,其他场景被标记为已跳过。有什么办法可以避免吗?
    • 什么是“反逗号”?
    【解决方案2】:

    据我所知,目前不可能使用标签运行测试。您可以在 github (https://github.com/cypress-io/cypress/issues) 中为此创建一个问题,让他们实现它。

    作为一种变通方法,我们选择创建烟雾测试和功能测试。烟雾测试位于单独的目录中,这使我们能够只运行那些测试场景而不是整个测试套件。您可以通过使用以下命令运行测试来做到这一点: npx cypress run --spec /cypress/smoketest/*

    【讨论】:

    • 我似乎没有以这种方式运行功能文件。可能只是规格。
    猜你喜欢
    • 2018-08-25
    • 1970-01-01
    • 2019-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-06
    • 2022-12-26
    相关资源
    最近更新 更多