Some functions are being executed again after the 2nd java file It should be 64Gb Black color these are shoppingjava files functions and they are showing again in the console | Selenium Training|Java|WebDriver|TestNG|Frameworks|Videos
10% May Month Discount Avail now

Selenium Training Forum

Some functions are being executed again after the 2nd java file It should be 64Gb Black color these are shoppingjava files functions and they are showing again in the console

N
Neha Bansal Post on 20/04/2019

I have two shopping hava files:

Shopping.java---------

package com;

import cucumber.api.java.en.And;

import cucumber.api.java.en.Given;

import cucumber.api.java.en.When;

public class Shopping {

@Given("I want to buy IphoneX")

public void I_want_Iphone() {

System.out.println("I want to buy an iPhone");

}

@And("it should be 64GB")

public void spacereq() {

System.out.println("It should be 64Gb");

}

@And("it should be black")

public void colorReq() {

System.out.println("Black color");

}

@When("I go to http://amazon.in")

public void loadSite() {

System.out.println("Go to amazon.in");

}

@And("I search for IphoneX")

public void search() {

System.out.println("Iphone X search");

}

}

 

Shopping2.java

package com;

 

import cucumber.api.java.en.Then;

import cucumber.api.java.en.When;

 

public class Shopping2 {

 

 

@Then("All search results should have IphoneX")

public void searchRes() {

System.out.println("All search results should have IphoneX");

}

 

@When("I select first search result")

public void selectSearchResult() {

System.out.println("Select first search result");

}

 

@Then("Next Page should open with the result")

public void nextPageValidation() {

System.out.println("Next Page should open with the new result");

}

}

 

Runner.java

package com;

 

import org.junit.runner.RunWith;

 

import cucumber.api.junit.Cucumber;

 

@RunWith(Cucumber.class)

public class MyRunner {

}

 

Console

I want to buy an iPhone

It should be 64Gb

Black color

Go to amazon.in

Iphone X search

All search results should have IphoneX

Select first search result

Next Page should open with the new result

It should be 64Gb

Black color

 

 

 

D

Instructor

Demo Reply on 20/04/2019

I guess your mappings from feature files are not OK