英文:
Java - Cucumber Tag Exclusion Not Working
问题
我已经创建了一个Cucumber运行器类,并且尝试通过包含一个Cucumber标签并排除另一个标签来运行特定的测试子集。我正在使用Maven作为项目管理工具。
package cucumber_runner;
import org.junit.runner.RunWith;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
@RunWith(Cucumber.class)
@CucumberOptions(features = "src/test/resources/features/",
glue = "stepdefinitions",
tags = {"@test", "~@homepage"})
public class RunCukesTest {
}
然而,在项目文件夹中运行`mvn test`的结果是,Cucumber测试根本没有运行。一旦我从标签中删除~字符,就像这样:`tags = {"@test", "@homepage"})`,测试会按预期执行,只考虑具有@test和@homepage标签的功能文件。请问如何正确地排除我的测试中的@homepage标签?
英文:
I have created a Cucumber runner class, and I am attempting to run a particular subset of tests by including one Cucumber tag and excluding another. I am using Maven as a project manager.
package cucumber_runner;
import org.junit.runner.RunWith;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
@RunWith(Cucumber.class)
@CucumberOptions(features = "src/test/resources/features/",
glue = "stepdefinitions",
tags = {"@test", "~@homepage"})
public class RunCukesTest {
}
The result of running mvn test
in the project folder, however, is that none of the Cucumber tests are run at all. Once I remove the ~ character from the tags, like so: tags = {"@test", "@homepage"})
, the tests execute as expected, only considering feature files that have both the @test and @homepage tags. How do I properly exclude the @homepage tag from my tests?
答案1
得分: 3
我在评论中被告知我使用的语法已被弃用,因此我查阅了新的语法:https://cucumber.io/docs/cucumber/api/#tags
将此留在这里供将来参考。
英文:
I have been told in the comments that the syntax I was using was deprecated, so I looked up the new syntax: https://cucumber.io/docs/cucumber/api/#tags
Leaving this here for future reference.
答案2
得分: 0
你可以尝试:
tags = "@test and @homepage"
英文:
You can try:
tags = "@test and @homepage"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论