黄瓜-在Java中实现缺少的步骤 [英] Cucumber - implementing missing steps in java

查看:249
本文介绍了黄瓜-在Java中实现缺少的步骤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我具有以下黄瓜功能,没有任何相应的Java代码动作。

  @CucumberTest 
场景:测试黄瓜
鉴于我已经进行了这项测试。
当我测试这个
时,我会得到这个

当我运行它时得到以下结果

  1个场景(1个未定义)
3个步骤(3个未定义)
0m0。 000s


您可以使用以下代码片段执行缺少的步骤:

Given( ^ I have this test\\。$,()- > {
//在此处编写代码,将上面的短语变为具体动作
抛出新的PendingException();
});

When( ^ I test This $,()-> {
//在此处编写代码,将上面的短语变为具体动作
抛出新的PendingException() ;
});

然后( ^ I get this $,()-> {
//在此处编写代码,将上面的短语变为具体动作
抛出新的PendingException() ;
});

但是我希望缺少的步骤在Java中,如下所示:

  @Given( ^我有这个测试\\。$)
public void I_have_this_test()抛出Throwable {
//在此处编写代码,将上面的短语变成具体的动作
throw new PendingException();
}

有人可以帮助我实现这一目标吗?

解决方案

您正在获取Java 8的代码片段。请与我们分享您的依赖关系。



我假设您有一个依赖项(使用Maven样式依赖项)

 < dependency> 
< groupId> info.cukes< / groupId>
< artifactId>黄瓜java8< / artifactId>
< version> 1.2.4< / version>
< / dependency>

相反,我想您想依靠

 < dependency> 
< groupId> info.cukes< / groupId>
< artifactId>黄瓜java< / artifactId>
< version> 1.2.4< / version>
< / dependency>

使用构建工具中的依赖项更新您的问题,我们也许可以为您提供更多帮助。 / p>

I have the below cucumber feature without any corresponding java code actions.

@CucumberTest
Scenario: Testing cucumber
 Given I have this test.
 When I test This
 Then I get this

When I run it I get the following results

    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();
    });

But I want the missing steps to be in java like the following :

    @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();
    }

Can anyone help me how I can achieve this ?

解决方案

You are getting code snippets for Java 8. Please share your dependencies with us.

I would assume that you have a dependency to (using Maven style dependencies)

<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-java8</artifactId>
    <version>1.2.4</version>
</dependency>

Instead, I think you would like to depend on

<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>1.2.4</version>
</dependency>

Update your question with your dependencies from your build tool and we might be able to help you more.

这篇关于黄瓜-在Java中实现缺少的步骤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆