如何忽略黄瓜中的特定场景? [英] How to ignore particular scenario in cucumber?

查看:28
本文介绍了如何忽略黄瓜中的特定场景?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 我使用黄瓜来提供场景和 Java 作为语言.
  2. 我需要在运行自动化测试时忽略特定场景.
  3. 我已尝试使用以下 @ignore 语法,但它根本不起作用.
  4. 它不会跳过特定场景,而是继续执行所有测试场景,我在功能文件中提供了这些测试场景.

<小时>

特征文件

@ActivateSegment
Feature: Test for Activate segment

  Scenario: Login
    Given I navigate to M
    And I enter user name 
    And I enter password 
    And I login to MM

  Scenario: Open grid
    Given I choose menu
    And I choose Segments menu

  Scenario: Open segment creation page
    Given I click on New button
    And I click on Segment button

推荐答案

使用标签 ~@tag_name

排除带有特定标签的场景

cucumber --tags ~@tag_name

注意我使用了~符号.

这里需要注意的一点是,如果您的 @wip-tagged 场景通过,Cucumber 将以 1 的状态退出(这是提醒他们在通过后不再进行中).

One thing to note here is that Cucumber will exit with a status of 1 if your @wip-tagged scenarios pass (it’s a reminder that they’re not works in progress anymore since they pass).

更新 1

示例场景

@billing
Feature: Verify billing

  @important
  Scenario: Missing product description

  Scenario: Several products

运行标签

cucumber --tags @billing            # Runs both scenarios
cucumber --tags @important          # Runs the first scenario
cucumber --tags ~@important         # Runs the second scenario (Scenarios without @important)

官方文档:https://github.com/cucumber/cucumber/wiki/Tags

这篇关于如何忽略黄瓜中的特定场景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆