O'Reilly logo

Cucumber Cookbook by Shankar Garg

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required