我有以下 cucumber 功能,没有任何相应的 java 代码操作。
@CucumberTest
Scenario: Testing cucumber
Given I have this test.
When I test This
Then I get this
当我运行它时,我得到以下结果
1 Scenarios (1 undefined)
3 Steps (3 undefined)
0m0.000s
You can implement missing steps with the snippets below:
Given("^I have this test\\.$", () -> {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
});
When("^I test This$", () -> {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
});
Then("^I get this$", () -> {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
});
但我希望缺少的步骤在 java 中,如下所示:
@Given("^I have this test\\.$")
public void I_have_this_test() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
任何人都可以帮助我如何实现这一目标吗?
最佳答案
您正在获取 Java 8 的代码片段。请与我们分享您的依赖项。
我假设您有一个依赖项(使用 Maven 样式依赖项)
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java8</artifactId>
<version>1.2.4</version>
</dependency>
相反,我认为您想依赖
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.4</version>
</dependency>
使用构建工具中的依赖项更新您的问题,我们也许能够为您提供更多帮助。
关于java - Cucumber - 在 java 中实现缺失的步骤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35300494/