gpt4 book ai didi

java - 如何排除 cucumber 标签

转载 作者:搜寻专家 更新时间:2023-10-30 21:25:35 27 4
gpt4 key购买 nike

我有一堆带有各种 cucumber 标签的 IT 案例。在我的主要运行者类(class)中,我想排除所有具有@one 或@two 的场景。所以,下面是我尝试过的选项 Option 1

@CucumberOptions(tags=Array("~@one,~@two"), .....)

选项2

@CucumberOptions(tags=Array("~@one","~@two").....

当我尝试使用选项一时,标有@two 的测试用例开始执行,而使用第二个选项则没有。根据 cucumber 文档,当标记被提及为 "@One,@Two" 时,将维护一个 OR。如果是这种情况,为什么不以相同的方式排除工作,即第一个选项?

更新:这段代码是用scala写的。

最佳答案

我想我知道它是如何工作的。

@Cucumber.Options(tags = {"~@one, ~@two"}) - 这转化为如果“@one 不存在”如果'@two is not there' 然后执行场景

因此以下功能中的所有场景都已执行。因为,第一个场景有标签@one 但没有@two。同样,第二个场景有标签@two 但没有@one。第三种情况既没有@one 也没有@two

Feature:
@one
Scenario: Tagged one
Given this is the first step

@two
Scenario: Tagged two
Given this is the first step

@three
Scenario: Tagged three
Given this is the first step

为了测试我的理解,我更新了功能文件如下。通过此更改,将执行所有没有标记@one 或@two 的场景。即@one @three、@two @three 和@three。

Feature:
@one @two
Scenario: Tagged one
Given this is the first step

@two @one
Scenario: Tagged two and one
Given this is the first step

@one @three
Scenario: Tagged one and three
Given this is the first step

@two @three
Scenario: Tagged two and three
Given this is the first step

@one @two @three
Scenario: Tagged one two and three
Given this is the first step

@three
Scenario: Tagged three
Given this is the first step

现在如果我们做一个 AND 操作:@Cucumber.Options(tags = {"~@one", "~@two"}) - 这意味着只有当 BOTH @one 和 @two 是时才执行场景不在那里。即使其中一个标签存在,它也不会被执行。因此,正如预期的那样,只执行了带有@three 的场景。

关于java - 如何排除 cucumber 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28408962/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com