Question

I have a maven project with two modules. I will just mention one of the modules here called app. Using my RunCukesTest class I am able to execute my single scenario and it can see that the first step has been defined and executes it. But IntelliJ's Gherkin plugin thinks my first step is undefined plus there is no code assistance from IntelliJ for me to be able to define a step in my step def class called LoginStepdefs. Why can't the Gherkin plugin find my step defs in class LoginStepdefs?

NB: The login.feature has the gherkin icon next to it and when hovering my mouse pointer over the first step it shows flyover text "Undefined step reference..."

The root pom.xml is:

<?xml version="1.0" encoding="UTF-8"?>
<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>jpro</groupId>
    <artifactId>jpro</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>
    <modules>
        <module>app</module>
    </modules>


</project>

In the app module the pom.xml is:

<?xml version="1.0" encoding="UTF-8"?>
<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">
    <parent>
        <artifactId>jpro</artifactId>
        <groupId>jpro</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>app</artifactId>

    <dependencies>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>1.1.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>1.1.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

The directory structure I have is:

jpro
    app
    pom.xml
        src
            main
            test
                java
                    pro
                        j
                            runner
                                RunCukesTest.java
                            stepdef
                                LoginStepdefs.java
                resources
                    feature
                        login.feature
       pom.xml

The file login.feature contains:

@SC_LOGIN
Feature: Login with username and password
  RQ_LOGIN_1: User can login using a username and password

  @SC_LOGIN_1 @RQ_LOGIN_1
  Scenario: Valid username and valid password
    Given I am not logged in
    When I go to the home page
    Then I should see the login page
    When I enter the username jpro
    And I enter the password password
    And I click the login button
    Then I should see that I am logged in as jpro
Était-ce utile?

La solution

I found out the solution. Install the Jetbrain's plugin called "Cucumber for Java". :)

I was trying to use the Gherkin plugin.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top