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

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

问题描述

  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标记的方案通过,则黄瓜将以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天全站免登陆