Cucumber V4 [io.cucumber] is not identifying @Give

2019-03-04 15:02发布

I am migrating from Cucumber Version 1.2.4 [<groupId>info.cukes</groupId>] to V.4.2.2 <groupId>io.cucumber</groupId>. After this, Cucumber Framework is not able to identify @Given/When/Then annotations and given error – The import cucumber.api.java.en.Given/When/Then cannot be resolved

Eclipse suggesting to add below dependency. But my thought is when I am migrating to Cucumber V4(io.cucumber) then why shall I add dependency of V1.2.4(info.cukes). Can someone suggest which is the correct dependency I shall add under V4 i.cucumber. which import i shall add to fix this issue. Can it be resolved without adding info.cukes -> cuucmber-java(1.2.4)

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

Below is the list of dependencies I have added under POM.xml. All are io.cucumber dependencies.

   <dependency>
                <groupId>io.cucumber</groupId>
                <artifactId>cucumber-core</artifactId>
                <version>4.2.2</version>
            </dependency>

            <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>4.2.2</version>
            </dependency>

            <dependency>
                <groupId>io.cucumber</groupId>
                <artifactId>cucumber-junit</artifactId>
                <version>4.2.2</version>
                <scope>test</scope>
            </dependency>

            <dependency>
                <groupId>io.cucumber</groupId>
                <artifactId>cucumber-jvm-deps</artifactId>
                <version>1.0.6</version>
                <scope>provided</scope>
            </dependency>

            <dependency>
                <groupId>io.cucumber</groupId>
                <artifactId>gherkin</artifactId>
                <version>6.0.14</version>
            </dependency>

            <dependency>
                <groupId>org.mockito</groupId>
                <artifactId>mockito-all</artifactId>
                <version>1.10.19</version>
                <scope>test</scope>
            </dependency>

            <dependency>
                <groupId>io.cucumber</groupId>
                <artifactId>cucumber-testng</artifactId>
                <version>2.0.0</version>
            </dependency>

            <dependency>
                <groupId>io.cucumber</groupId>
                <artifactId>cucumber-picocontainer</artifactId>
                <version>2.1.0</version>
                <scope>test</scope>
            </dependency>

Please help me to understand how this error can be resolved under cucumber v4. I do not want to use info.cukes maven id as it does not have V4. So please guide

标签: cucumber
1条回答
再贱就再见
2楼-- · 2019-03-04 15:03

I have resolved the issue and sharing correct set of dependency. Please add JUnit/TestNG based on your framework requirement.

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>4.2.3</version>
</dependency>

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>4.2.3</version>
    <scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
    <scope>test</scope>
</dependency>

     <!-- https://mvnrepository.com/artifact/io.cucumber/datatable -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>datatable</artifactId>
    <version>1.1.12</version>
</dependency>

    <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-testng -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-testng</artifactId>
    <version>4.2.3</version>
</dependency>

    <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-picocontainer -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-picocontainer</artifactId>
    <version>4.2.3</version>
    <scope>test</scope>
</dependency>
查看更多
登录 后发表回答