Cucumber stubs not generating correctly

345 views
Skip to first unread message

knoll2roll

unread,
Jun 24, 2016, 6:48:56 AM6/24/16
to Cukes
Hi guys,

I am using cucumber jvm version 1.2.4

When i run a feature file with no step definitions defined, the sub generation is appearing like this:

Given("^I am doing somthing$", () -> {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
});

I have no idea why it is not generating correctly. My run file is:

import cucumber.api.CucumberOptions;
import cucumber.api.SnippetType;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(
plugin = {"pretty", "html:target/cucumber", "junit:target/junit_cucumber.xml", "json:target/cucumber.json"},
features = "src/test/resources/features",
tags = {"~@wip", "~@manual"},
monochrome = true,
snippets = SnippetType.CAMELCASE)
public class RunCukesTest {
}

Any help would be greatly appreciated.

Kind regards,
Knoll

Paolo Ambrosio

unread,
Jun 25, 2016, 3:19:10 AM6/25/16
to cu...@googlegroups.com
On Fri, Jun 24, 2016 at 11:48 AM, knoll2roll <knoll...@gmail.com> wrote:

> Hi guys,
>
> I am using cucumber jvm version 1.2.4
>
> When i run a feature file with no step definitions defined, the sub
> generation is appearing like this:
>
> Given("^I am doing somthing$", () -> {
> // Write code here that turns the phrase above into concrete actions
> throw new PendingException();
> });
>
> I have no idea why it is not generating correctly.

What is incorrect in that snippet? What were you expecting?

Usman Hussain

unread,
Jun 25, 2016, 6:53:38 AM6/25/16
to cu...@googlegroups.com
Hi Paolo,

When I add the snippet to my java class I get errors. What I was expecting was:

@Given("^I am doing somthing$")
public void iAmDoingSomething() throws Throwable {

// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}


Unless I am missing something...
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Roberto Lo Giacco

unread,
Jun 25, 2016, 7:51:44 AM6/25/16
to Cukes
Il giorno sabato 25 giugno 2016 12:53:38 UTC+2, Usman Hussain ha scritto:
Hi Paolo,

When I add the snippet to my java class I get errors. What I was expecting was:

@Given("^I am doing somthing$")
public void iAmDoingSomething() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}


Unless I am missing something...

 
Which version of Java are you using to run your tests? Which version of Java (or Java Compiler Option) do you use to compile your snippets?

To me this looks like the generated snippet uses lambda while your IDE/compiler is either not supporting lambda or configured for a backward compatibility.

Roberto

knoll2roll

unread,
Jun 25, 2016, 9:37:30 AM6/25/16
to Cukes
I am using java 1.8
cucumber 1.2.4
mvn 3.3.9

and i am running mvn clean test from the command line.

I am on a windows 10 machine.

am really confused! 

Björn Rasmusson

unread,
Jun 25, 2016, 10:34:00 AM6/25/16
to Cukes
knoll2roll wrote:
I am using java 1.8
cucumber 1.2.4
mvn 3.3.9

and i am running mvn clean test from the command line.

I am on a windows 10 machine.

am really confused! 

On Fri, Jun 24, 2016 at 11:48 AM, knoll2roll <knoll...@gmail.com> wrote:

> Hi guys,
>
> I am using cucumber jvm version 1.2.4
>
> When i run a feature file with no step definitions defined, the sub
> generation is appearing like this:
>
> Given("^I am doing somthing$", () -> {
>     // Write code here that turns the phrase above into concrete actions
>     throw new PendingException();
> });
>
> I have no idea why it is not generating correctly.
 
Since you are using java 1.8, you get Java8 lambda snippets.
When you copy them you need to define them in the constructor that implements cucumber.api.java8.En (or another i18n language), like here:
https://github.com/cucumber/cucumber-jvm/blob/master/java8/src/test/java/cucumber/runtime/java8/test/LambdaStepdefs.java

The snippet generation is just suggestions, you can or course also define the Java7 method type step definitions if you rather want to use them.

Regards
Björn

Reply all
Reply to author
Forward
0 new messages