【发布时间】:2022-07-21 18:38:25
【问题描述】:
我有一个奇怪的问题,Cucumber 无法识别标签。我想从执行中排除一个场景,但它仍在执行中。我使用的是黄瓜 6.10.2 版本(io.cucumber)。
所以场景是:
@tag1
Scenario Outline: Attempt to Create Contract
Given I delete all test data for <some collection name>
And I delete all test data for <other collection name>
我的跑步者班级是:
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(
features = "src/test/java/resources"
, glue = {"stepDefinitions"}
, plugin = {"pretty", "html:target/cucumber-reports",
"html:target/cucumber-report/cucumber.html",
"html:target/cucumber-report.html",
"json:target/cucumber.json"}
, tags = "not @tag1"
)
public class RuneCukeTest {
}
我还尝试了不同的标签语法,例如:
tags = ~"@tag1"
tags = "~@tag1"
但没有一个工作。 (即使我尝试只运行这个标签)。 它不允许我这样输入,可能是因为版本:
tags = {"@tag1"}
我在“标签”文档下找到的是:
String tags() default "";
上面的例子“@smoke 而不是@fast”
注意事项:
我使用的 .feature 文件很少,我只想执行一个并从中跳过 1 个场景。我正在尝试两者 - 使用 @CucumberOptions 从运行器类执行它,并通过右键单击 .feature 文件本身。没有任何效果...
【问题讨论】:
-
你试过
tags = "{@feature not @tag1)"吗? (其中@feature是功能文件最顶部使用的标签)。您也可以尝试使用波浪号。 -
是的,它还没有工作:/