Search code examples
mavencucumbercucumber-java

Got the output as 0 Scenarios when run the test runner


I am trying to run some test as part of learing cucumber. But I got the result as 0 scenarios. Here I am adding the code I have written:

Login.feature with-

Feature: Application Login   S
Scenario : Home page default login

    Given User is on Net banking landing page
    When user login into the application with  username and password
    Then Home page is populated
    And Cards are displayed

Step Definition:

package stepDefinitions;

import cucumber.api.PendingException;

import cucumber.api.java.en.Given;

import cucumber.api.java.en.When;

import cucumber.api.java.en.Then;

import cucumber.api.java.en.And;

import cucumber.api.junit.Cucumber;

import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
public class StepDefinition {

    @Given("^User is on Net banking landing page$")
    public void user_is_on_net_banking_landing_page() throws Throwable {
        System.out.println("User on landing page");
    }

    @When("^user login into the application with  username and password$")
    public void user_login_into_the_application_with_username_and_password() throws Throwable {
        System.out.println("Login successfully");
    }

    @Then("^Home page is populated$")
    public void home_page_is_populated() throws Throwable {
        System.out.println("User on Home page");
    }

    @And("^Cards are displayed$")
    public void cards_are_displayed() throws Throwable {
        System.out.println("Displaying cards");
    }

}

Test Runner -

package com.edstem.CucumberOptions;

import cucumber.api.CucumberOptions;

import cucumber.api.junit.Cucumber;

import org.junit.runner.RunWith;

@RunWith(Cucumber.class)

@CucumberOptions(
            features = "src/test/java/features",
            glue = {"stepDefinitions"})

public class TestRunner {
}

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>org.example</groupId>
    <artifactId>cucumber-learning</artifactId>
    <version>1.0-SNAPSHOT</version>

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

    <dependencies>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java8</artifactId>
            <version>RELEASE</version>
            <scope>test</scope>
        </dependency>

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

        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-picocontainer</artifactId>
            <version>RELEASE</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>


        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-jvm</artifactId>
            <version>1.0.11</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>datatable</artifactId>
            <version>1.1.12</version>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-testng</artifactId>
            <version>4.2.3</version>
        </dependency>


    </dependencies>

</project>

Output: 0 Scenarios 0 Steps 0m0.000s

Process finished with exit code 0features = "src/test/java/features",

Could you give me a solution, as I cannot find a way to fix it.


Solution

  • The space between Scenario and : is the issue

    Replace this

    Scenario : Home page default login
    

    With

    Scenario: Home page default login