Java – Cucumber 标签排除未生效

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

Java - Cucumber Tag Exclusion Not Working

问题

  1. 我已经创建了一个Cucumber运行器类并且尝试通过包含一个Cucumber标签并排除另一个标签来运行特定的测试子集我正在使用Maven作为项目管理工具
  2. package cucumber_runner;
  3. import org.junit.runner.RunWith;
  4. import io.cucumber.junit.Cucumber;
  5. import io.cucumber.junit.CucumberOptions;
  6. @RunWith(Cucumber.class)
  7. @CucumberOptions(features = "src/test/resources/features/",
  8. glue = "stepdefinitions",
  9. tags = {"@test", "~@homepage"})
  10. public class RunCukesTest {
  11. }
  12. 然而在项目文件夹中运行`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.

  1. package cucumber_runner;
  2. import org.junit.runner.RunWith;
  3. import io.cucumber.junit.Cucumber;
  4. import io.cucumber.junit.CucumberOptions;
  5. @RunWith(Cucumber.class)
  6. @CucumberOptions(features = "src/test/resources/features/",
  7. glue = "stepdefinitions",
  8. tags = {"@test", "~@homepage"})
  9. public class RunCukesTest {
  10. }

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

你可以尝试:

  1. tags = "@test and @homepage"
英文:

You can try:

  1. tags = "@test and @homepage"

huangapple
  • 本文由 发表于 2020年4月7日 07:07:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/61070334.html
匿名

发表评论

匿名网友

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

确定