Identifying Duplicate and Ambiguous Step Definitions

Sometimes when we are writing Cucumber Step Definitions files, we get either Duplicate Step Definitions errors or Ambiguous Step Definitions errors. Let's try and understand the reasons why these errors arise, and how we can remove them through this recipe.

How to do it…

We will use the same Feature file from previous recipe. Perform the following Steps:

  1. Let's create one more class in the StepDefinitions package, called DuplicateAmbiguous.java, with the following content:
    package com.StepDefinitions; import cucumber.api.java.en.Given; public class DuplicateAmbiguous { //Duplicate Steps @Given("^user is on Application landing page$") public void user_is_on_Application_landing_page_duplicate() throws ...

Get Cucumber Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.