0
votes

I am having issue with Cucumber JVM not being able to pick up the step definitions. I do have @CucumberOptions in the Runner file. My feature file does have @smokeTest tag as well. Still the issue persists for me. Please help!I've been trying to resolve this for few days now.

Maven and Java version:

Apache Maven 3.0.4 Java version: 1.6.0_65, vendor: Apple Inc.

Project structure:

  1. Demo --> src --> test --> java --> com.smoke.test --> Runner.java | SmokeTestStepDef.java
  2. Demo --> src --> test --> resources --> featureDemo.feature

Runner file:

package com.smoke.test;

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

@RunWith(Cucumber.class)
@CucumberOptions(format={"pretty","html:reports/test-report"},tags= "@smokeTest")

public class Runner {
}

pom.xml:

<?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>com.demo</groupId>
    <artifactId>cumcumberdemo</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>2.41.0</version>
        </dependency>

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

    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-jvm</artifactId>
        <version>1.1.7</version>
        <type>pom</type>
    </dependency>

    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>1.1.7</version>
        <scope>test</scope>
    </dependency>
    </dependencies>

</project>
2
How do you write your .feature? Because it is on the right path, but seems that cucumber can't identify the steps, could you add in your question?Pedro Henrique
@PedroHenrique : Do you mean what is the Gherkin script in the feature file?justCurious
Yes, one time I had a problem like this, and the error was on the .feature filePedro Henrique
Feature: Add two numbers Scenario: Validate addition of two numbers Given I have a calculator When I add 2 and 3 Then the result is 5justCurious
@justCurious Can you please edit your question with your actual feature file (including cucumber tag if any)?Sébastien Le Callonnec

2 Answers

1
votes

Move featureDemo.feature under src/test/resources/com/smoke/test.

As Eugene mentioned, it looks like a glue issue but from your comments, there seems to be another feature file in your project that's hiding the problem that it's actually the feature file that cannot be found.

0
votes

I think you have to define your glue path in @CucumberOptions as well. This is where your step definitions reside. It is described here.