首页 > 解决方案 > Citrus cucumber 不提供睡眠的默认实现

问题描述

我正在使用 citrus 框架(2.7.6,也使用 2.8.0-SNAPSHOT 测试)来端到端测试应用程序。在创建测试时,我注意到文档具有默认的睡眠和回声方法,如 33.9 和 33.10 的文档中所述(https://citrusframework.org/citrus/reference/2.7.5/html/index.html#sleep-steps)。但是,以下功能文件抱怨未提供实现:

Feature: Test
  Scenario: Sleep test
    Given echo "hi"
    Then sleep 50 ms

结果是:

You can implement missing steps with the snippets below:
@Then("sleep {int} ms")
public void sleep_ms(Integer int1) {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

@Given("echo {string}")
public void echo(String string) {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

我应该在哪里寻找解决方案的任何提示?

我编写的步骤运行良好,只是似乎缺少默认值。

标签: cucumbercitrus-framework

解决方案


听起来您没有将默认的 Citrus 步骤实现包作为胶水添加到您的 @CucumberOptions 注释中。您需要将以下内容添加到您的测试类中:

@CucumberOptions(glue = { "com.consol.citrus.cucumber.step.runner.core" })

这个包包含“echo”和“sleep”的默认步骤实现。


推荐阅读