cucumber-java and cucumber-junit after version 1.0.14 does not work

35,021

Solution 1

@Cucumber.Options is deprecated use @CucumberOptions instead

@CucumberOptions(
    format = "pretty",
    features = "//refer to Feature file"  
)

Hope this helps you

Solution 2

The annotation has changed to @CucumberOptions:

And I think json-pretty has changed to json in this cucumber version.

This should work:

@CucumberOptions(
      format = {"pretty", "html:target/cucumber-htmlreport","json:target/cucumber-report.json"}
)

Moreover, according to cucumber-jvm specifications format is deprecated. You should replace by plugin. This also should work:

plugin = {"pretty", "html:target/cucumber-htmlreport","json:target/cucumber-report.json"}

Hope it helps

Solution 3

with cucumber 1.2.2

<cucumber.version>1.2.2</cucumber.version>
....
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>${cucumber.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>${cucumber.version}</version>
        <scope>test</scope>
    </dependency>
....

here a sample working test:

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(features = "classpath:features/myfeature.feature", tags = "@Mytag", plugin = {"pretty", "html:target/cucumber"})
public class MYAcceptanceTest {

}

note the import is cucumber.api.junit.Cucumber instead of cucumber.junit.Cucumber and you need to add the import for the cucumber options. The stereotype for the option is @CucumberOptions instead of @Cucumber.Options

Solution 4

replace @Cucumber.Options with @CucumberOptions and format with plugin

@CucumberOptions(plugin = {"pretty", "html:target/cucumber-htmlreport","json-pretty:target/cucumber-report.json"})
public class RunCukesTest {
}

Solution 5

You can try putting both RunCukesTest.java file and your Feature file in same folder or package.

Share:
35,021
Ripon Al Wasim
Author by

Ripon Al Wasim

[email protected] skype: ripon_sky

Updated on February 22, 2020

Comments

  • Ripon Al Wasim
    Ripon Al Wasim about 4 years

    I am using Cucumber-JVM and Selenium WebDriver together. I have a Maven project in eclipse and dependency of pom.xml file is as below:

    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>1.2.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>1.2.2</version>
        <scope>test</scope>
    </dependency>
    

    The content of RunCukesTest.java file is:

    import org.junit.runner.RunWith;
    import cucumber.junit.Cucumber;
    @RunWith(Cucumber.class)
    @Cucumber.Options(format = {"pretty", "html:target/cucumber-htmlreport","json-pretty:target/cucumber-report.json"})
    public class RunCukesTest {
    }
    

    I am getting the error in the following lines of code:

    import cucumber.junit.Cucumber;
    @RunWith(Cucumber.class)
    @Cucumber.Options(format = {"pretty", "html:target/cucumber-htmlreport","json-pretty:target/cucumber-report.json"})
    

    But when I used the version 1.0.14 it works well. What's the wrong with the latest version?