【问题标题】:Cucumber 2.4.0 tags not working with Gradle 4.6Cucumber 2.4.0 标签不适用于 Gradle 4.6
【发布时间】:2018-09-29 21:06:09
【问题描述】:

我正在尝试使用标签从 Gradle 运行 Cucumber 以运行不同的测试集

在开发中我想运行 Eat cukes 场景:

./gradlew -Dcucumber.options="--tags @dev" clean test

在专业版中,我想运行吃蘑菇场景:

./gradlew -Dcucumber.options="--tags @pro" clean test

问题在于 gradle/cucumber 似乎忽略了 cucumber.options 标签 信息并且总是运行所有测试。我已经用 Maven 尝试了相同的示例并且它有效。不幸的是,我需要它与 Gradle 一起运行。有什么想法吗?

我的测试运行器是 junit-jupiter 5.1.0,带有 junit-platform-launcher 1.1.0、junit-jupiter-engine 5.1.0 和 junit-vintage-engine 5.1.0。

@RunWith(Cucumber.class)
public class CucumberTest {

}

特点:

Feature: Restaurant

  @dev
  Scenario: Eat cukes

    Given I have 10 cukes in my belly
    Then I eat 1 more cukes

  @pro
  Scenario: Eat mushrooms

    Given I have 10 mushrooms in my belly
    Then I eat 1 more mushrooms

开发步骤定义:

public class RestaurantStepDef implements En {

    public RestaurantStepDef() {
        Given("I have (\\d+) cukes in my belly", (Integer cukes) -> System.out.format("Cukes: %n\n", cukes));
        Then("I eat (\\d+) more cukes", (Integer number) -> assertEquals((Integer) 2, number));
    }

}

专业步骤定义:

public class RestaurantStepDef2 implements En {

    public NavegationStepDef2() {
        Given("I have (\\d+) mushrooms in my belly", (Integer cukes) -> System.out.format("Mushrooms: %n\n", cukes));
        Then("I eat (\\d+) more mushrooms", (Integer number) -> assertEquals((Integer) 2, number));
    }

}

【问题讨论】:

标签: gradle junit cucumber cucumber-jvm junit5


【解决方案1】:

Gradle 将测试执行分叉到不同的 JVM 中,因此不会继承初始系统属性

将此添加到您的 gradle 文件中

test { systemProperty "cucumber.options", System.getProperty("cucumber.options") }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-15
    • 2014-08-17
    • 1970-01-01
    • 2021-11-06
    • 2013-08-26
    相关资源
    最近更新 更多