Ash
Ash

Reputation: 592

Cucumber feature file does not identify the steps

I have written my firsy cucumber feature file. When I run the feature file as Cucumber Feature, I get below errors

  1. "WARNING: Cucumber-JVM's --format option is deprecated. Please use --plugin instead." - I used "plugin" in my @CucumberOptions of runner class, but still getting the same error

2.It says I do not have any scenario and steps Feature: Validate Modular GUI pages

Scenario: Validate Login Page # C:/Selenium/RegressionTest/ModularRegression/src/GUI/features/Validate.feature:3 Given: Modular GUI is opened When: Validate the login page Then: Login to the Modular

0 Scenarios 0 Steps

  1. I'm not getting snippets for my steps.

I have added following jars to the library Jars

This is my runner class, package GUI;

import org.junit.runner.RunWith;

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

@RunWith(Cucumber.class)
@CucumberOptions(
        format = {"pretty", "json:target/"},
        features = {"src/GUI/"}
        )
public class GUIRunner {

}

This is my feature file,

Feature: Validate Modular GUI pages

  Scenario: Validate Login Page
    Given: Modular GUI is opened
    When: Validate the login page
    Then: Login to the Modular

I would really appreciate if someone can point out what is missing in my code.

Thank you very much

[EDITED] This is the actual error:

WARNING: Cucumber-JVM's --format option is deprecated. Please use --plugin instead. Feature: Validate Modular GUI pages

Scenario: Validate Login Page # C:/Selenium/RegressionTest/ModularRegression/src/GUI/features/Validate.feature:3 Given: Modular GUI is opened When: Validate the login page Then: Login to the Modular

0 Scenarios 0 Steps 0m0.000s

Upvotes: 5

Views: 65286

Answers (7)

Replace format with plugin as format option was deprecated from v1.2.0 onwards on 30-October-2014. Example below -

@RunWith(Cucumber.class)
@CucumberOptions(features = "classpath:features/functional/",
                     glue = {"com.jacksparrow.automation.steps_definitions.functional" },
                   plugin = { "pretty","json:target/cucumber-json/cucumber.json",
                            "junit:target/cucumber-reports/Cucumber.xml", "html:target/cucumber-reports"},
                   tags = { "@BAMS_Submitted_State_Guest_User" },
                   strict = false,
                   dryRun = false,
               monochrome = true)

Upvotes: 0

Ash
Ash

Reputation: 592

I had an extra ":" in my feature file after Given, When and Then.

It's working now.

Upvotes: 6

Ch Rajeshwar Reddy
Ch Rajeshwar Reddy

Reputation: 1

please add tags= {"@SmokeTest","@RegressionTest"} in @CucumberOptions()

Upvotes: 0

Charan Rao
Charan Rao

Reputation: 1

Please add tags = {"@SmokeTest"} or tags = {"@RegresionTest"}

Upvotes: 0

wondersz1
wondersz1

Reputation: 905

Just to add to the existing answers: remember to write "Scenario: " before writing actual code of the step. That might seem absolutely trivial, but without it you'll always be getting "0 features, 0 steps" message.

Source: https://www.youtube.com/watch?v=WuTKWwD37Tg

Upvotes: 0

Bhuvanesh Mani
Bhuvanesh Mani

Reputation: 1464

Where are your step definitions located? Try adding the tag 'glue' like below

@RunWith(Cucumber.class)
@CucumberOptions(
        format = {"pretty", "json:target/"},
        features = {"src/GUI/"},
        glue = {"path/to/steps"} 
        )
public class GUIRunner {

}

Upvotes: 0

Thomas Sundberg
Thomas Sundberg

Reputation: 4343

You are missing your feature files in your class path.

You don’t tell us how you are running Cucumber. But if you would run it as a part of a Maven build, which is among the easier options, you would like to store your feature file in

./src/test/resources/GUI

An easy way to get started is to download the getting started project from GitHub, https://github.com/cucumber/cucumber-java-skeleton

It will give you a a working project that you can modify to contain your problem.

Upvotes: 1

Related Questions