忽略 Cucumber 中特定的标签,但运行其他所有标签。

huangapple go评论68阅读模式
英文:

Ignore particular tag in cucumber but run all other tags

问题

我有一个场景,在这个场景中,我需要运行多个标签,并且在发生某个条件时不需要运行另一个标签。当浏览器是IE时,我不想运行Feature_1。

@run_me @do_not_run
Feature 1

@Tag1 @Tag2
Scenario: 场景 1
@run_me
Feature 2

@Tag1 @Tag3
Scenario: 场景 2

条件:

if(browser == "IE"){
    当存在 @do_not_run 标签时执行所有 @run_me 标签但不要执行带有 @do_not_run 标签的部分
}
否则
    运行所有 @run_me

当前代码:

--tags @run_me

实现这个目标的正确方法是什么?

注:
我尝试过在 if 条件内使用 --tags @run_me ~@do_not_run。但不确定是否是正确的方法。

英文:

I have a scenario, where I need to run multiple tags and need not run another one when a condition occurs. I don't want to run Feature_1 when the browser is IE.

@run_me @do_not_run
Feature 1
    
@Tag1 @Tag2
Scenario: Scenario 1

@run_me
Feature  2
    
@Tag1 @Tag3
Scenario: Scenario 2

Condition:

if(browser == "IE"){
    then execute all @run_me tags but don't execute it when there is @do_not_run
else
    run all @run_me

Current code:

--tags @run_me

What should be the right way to achieve it?

Note:
I tried --tags @run_me ~@do_not_runinside the if condition. But not sure it is the correct method or not.

答案1

得分: 1

你可以按照以下方法执行标签。

  1. @fast -- 使用 @fast 标记的场景
  2. @wip 并且不是 @slow -- 使用 @wip 标记但不同时也使用 @slow 标记的场景
  3. @smoke 和 @fast -- 同时使用 @smoke 和 @fast 标记的场景
  4. @gui 或者 @database -- 使用 @gui 或者 @database 标记的场景

参考链接

英文:

You can follow below approach to execute the tags.

  1. @fast -- Scenarios tagged with @fast
  2. @wip and not @slow -- Scenarios tagged with @wip that aren’t also tagged with @slow
  3. @smoke and @fast -- Scenarios tagged with both @smoke and @fast
  4. @gui or @database --Scenarios tagged with either @gui or @database

Reference Link

huangapple
  • 本文由 发表于 2020年9月15日 00:49:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/63888642.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定