0

After running my test, Cucumber says my step is undefined. Did I do something wrong?

Feature:

Then I should see Error message for "ORIGIN" zipcode with key <messageKey> 

Step definition:

@Then("^I should see Error message for \"([^\"]*)\" zipcode with key ([^\\\"]*)$") public void i_should_see_Error_message_for_zipcode_with_key(String location, String messageKey) 
1
  • Can you provide an example of a messageKey? Your regex match for it is pretty specific; either your format is that specific or you need to loosen it up a bit. Commented Mar 31, 2020 at 15:23

1 Answer 1

1

Finally I have got the answer. Cucumber searches between feature files and step definitions character by character; so if you have too many steps sharing the same name and cucumber confuses which is which giving you "Undefined" steps with the following error, just change the name of your stepDefs. Error: "You can implement missing steps with the snippets below:"

Sign up to request clarification or add additional context in comments.

1 Comment

if you have multiple steps with the same name then you will get DuplicateStepDefinitionException. I am quite sure above step in my answer was missing in your solution hence you got undefined step exception during runtime

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.