cucumber-java and cucumber-junit after version 1.0.14 does not work
Asked Answered
G

7

5

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?

Gorga answered 8/7, 2015 at 7:10 Comment(2)
what error message do you have?Tate
The import cucumber.junit cannot be resolved for "import cucumber.junit.Cucumber;" and Multiple markers at this line - Cucumber cannot be resolved to a type - Class<Cucumber> cannot be resolved for next 2 lines of codeGorga
T
10

@Cucumber.Options is deprecated use @CucumberOptions instead

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

Hope this helps you

Tepee answered 8/7, 2015 at 9:30 Comment(0)
R
5

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

Resigned answered 8/7, 2015 at 9:29 Comment(0)
T
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

Tate answered 8/7, 2015 at 9:30 Comment(0)
T
2

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 {
}
Trioxide answered 7/11, 2017 at 10:13 Comment(0)
G
1

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

Granophyre answered 15/10, 2016 at 22:27 Comment(0)
B
1

Cucumber version is now updated to version 2.0.1. Replace

<groupId>info.cukes</groupId>

with

<groupId>io.cucumber</groupId>
Berthaberthe answered 9/11, 2017 at 11:55 Comment(0)
B
0

By Adding Below Dependencies above issue got resolved

Please list of dependencies added in the POM

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>FirstBBDApp</groupId>
    <artifactId>FirstBBDApp</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>FirstBBDApp</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-picocontainer</artifactId>
            <version>1.2.5</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>1.2.5</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-junit -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>1.2.5</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-core -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-core</artifactId>
            <version>1.2.5</version>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-jvm</artifactId>
            <version>1.2.5</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>net.masterthought</groupId>
            <artifactId>cucumber-reporting</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-jvm-deps</artifactId>
            <version>1.0.3</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-html -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-html</artifactId>
            <version>0.2.6</version>
        </dependency>
        <dependency>
            <groupId>net.sourceforge.cobertura</groupId>
            <artifactId>cobertura</artifactId>
            <version>2.1.1</version>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>gherkin</artifactId>
            <version>2.12.2</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/info.cukes/gherkin-jvm-deps -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>gherkin-jvm-deps</artifactId>
            <version>1.0.3</version>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>2.0.2-beta</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/junit/junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.7.1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/junit/junit-dep -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit-dep</artifactId>
            <version>4.11</version>
            <type>pom</type>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-chrome-driver</artifactId>
            <version>3.14.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.sun</groupId>
            <artifactId>tools</artifactId>
            <version>1.6</version>
            <scope>system</scope>
            <systemPath>C:\Program Files\Java\jdk1.8.0_202\lib\tools.jar</systemPath>
        </dependency>
    </dependencies>
</project>
Bregma answered 5/2, 2019 at 9:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.