Gautam
Gautam

Reputation: 3386

Facing issue while running Cucumber scenario

I am new to Cucumber and facing weird issue while running particular cucumber Scenario. Below are two Scenario which I defined in my feature file. first Scenario works without any problem but cucumber doesn't even consider second one while running test cases.

Scenario Outline: 
1.Validate create  functionality

Given user is on "Home" screen
When click on Create
Then create screen should render


Scenario Outline: 
2.Validate create  Name,Description,Start Date


    Given user is on create screen
    When user enters following values:

            |  Name                   | dummyName       |
            | Desc                    | dummyDesc@#     |
            | Date                    | ghgh            |   

    Then there should be error message on the screen.

Below is the feature implementation method in java

Scenario 1.

@Given("^user is on \"([^\"]*)\" screen$")
    public void homeScreen(String home) throws Throwable {
        //someCode
    }

@When("^click on Create$")
    public clickCreate() throws Throwable {
        //someCode
    }

@Then ("^create screen should render$")
    public void createRender() throws Throwable {
        //someCode
    }

Scenario 2.

@Given("^user is on create screen$")
    public void crateScreen() throws Throwable {
        //someCode
    }


@When("^user enters following values :$")
public void EnterValues(Map<String,String> map) throws Throwable {
        //someCode
    }

@Then("^there should be error message on the screen.$")
public void errorMessage() throws Throwable {
        //someCode
    }

Why Scenario is not invoked by Cucumber?

Environment- Cucumber,Selenium,JAVA

Upvotes: 0

Views: 1303

Answers (1)

Vishal Aggarwal
Vishal Aggarwal

Reputation: 4181

Because you are not using any placeholders around variable names used in example table.In fact I see lot of gherkin syntax issues anyways in your code.Try this:

Scenario Outline: Validate Input Fields
 Given user is on create screen
 When user enters following values <createName>,<Description>,<StartDate>
 Then should receive this <ErrorMessage>

 Examples:
   | createName| Description| StartDate| ErrorMessage|
   | DummyName| dummyDesc@#| ghgh| Invalid Date Entered |

Upvotes: 1

Related Questions