Question

Question may sound novice. But here i am everytime i try writing iphone5 in my cucumber feature file it parameterises the 5. I dont want this to happen and want it to just treat iphone5 as a string.

The line in my feature file causing this is: Then upload iPhone5 image "xxxx.png"

which then gets following step definition:

@And("^then upload iPhone(\\d+) image \"([^\"]*)\"$")
public void then_upload_iPhone_image(int arg1, String arg2) throws Throwable {
    // Express the Regexp above with the code you wish you had
    throw new PendingException();
}
Était-ce utile?

La solution

Just remove regex for the digit and remove the parameter from the method.

@Given("^I upload to iphone5$")
public void I_upload_to_iphone() throws Throwable {
    // Express the Regexp above with the code you wish you had
    throw new PendingException();
}

in your case

@And("^then upload iPhone5 image \"([^\"]*)\"$")
public void then_upload_iPhone_image(String arg2) throws Throwable {
    // Express the Regexp above with the code you wish you had
    throw new PendingException();
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top