我有一堆带有各种黄瓜标签的IT案例。在我的主运行类中,我想排除所有有@one或@two的方案。所以,下面是我试过的选项 选择1
@CucumberOptions(tags=Array("~@one,~@two"), .....)
或 方案二
@CucumberOptions(tags=Array("~@one","~@two").....
当我尝试使用选项一时,带有@two标签的测试用例开始执行,而使用第二个选项时则没有。"@One,@Two"
. 如果是这样的话,为什么排除的方式不和第一个选项一样呢?
更新:这段代码是用scala写的。
我想我知道它是如何工作的了。
@Cucumber.Options(tags = {"~@one, ~@two"})
- 它的意思是如果"@1不在那里 或 如果'@two不在',则执行场景
所以,下面功能中的所有场景都被执行。因为,第一个场景有标签@1,但没有@two。同样的,第二个场景有标签@two,但没有@one。第三种情况既没有@1也没有@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
为了测试我的理解,我更新了如下的功能文件。通过这个改变,所有没有标签@1或@two的场景都被执行了,即@1 @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"})
- 这意味着只有当 两者 @一和@二都不存在。即使其中一个标签在那里,也不会被执行,所以正如预期的那样,只有@three的场景被执行。
是否有可能它不喜欢Array,也许可以试试。
@CucumberOptions(tags={"~@one,~@two"}, .....)
一般来说,标签背后有以下逻辑。
AND逻辑是这样的:
tags = {"@Tag1", "@Tag2"} //both tags must be present or:
tags = {"~@Tag1", "~@Tag2"} // both tags must not be present,
//if only one is the stuff will be executed!
OR逻辑是这样的
tags = {"@Tag1, @Tag2"} //one of these Tags must be present or:
tags = {"~@Tag1, ~@Tag2"} //one of these Tags must not be present, the Rest will be executed!
但是我发现,黄瓜很快就会在标签中支持 "or"-操作符,并取代逗号+""-stuff......,这样就更容易表达出差异。这是要像。
tags = {"@Tag1 or @Tag2"}
系统的原始信息是:
Support for '@tag1,@tag2' will be removed from the next release of Cucumber-JVM. Please use '@tag or @tag2' instead
希望以后也能帮到你 :)