JBehave Ambiguous Steps

In this post, we will discuss JBehave Ambiguous Steps.

What is an Ambiguous Step?

If the gherkin matches more than one matching steps, then it is called an Ambiguous Step. An ambiguous step, matches multiple methods in step classes. Also, this often happens in large projects while writing number of stories. However, the story editor for example, eclipse plugin editor , warns you about ambiguous steps if the steps are statically defined. Furthermore, ambiguous steps lead to undesirable execution if we don’t prioritize them or define a prioritizing strategy.

Example:

We will see some simple example below to clarify things. Lets us take a simple gherkin text below which matches 2 matching steps:
Given bing search homepage

We have made the above gherkin text to match 2 steps as shown in below picture. Two step candidates have been provided i.e two different implementations in step classes for the same gherkin textual step. We may need to resolve this ambiguity either by resolving the ambiguity or setting priority to steps.

 

JBehave_Ambigious_Steps1

Warning shown by the story editor:

Ambiguous step: 2 steps are matching <Given bing search homepage > got: [[GIVEN]bing search homepage, BingSteps#openBing, [GIVEN]bing search homepage, CommonSteps#openBing]

bing search homepage (com.testingdocs.stock.steps.BingSteps.java#openBing)
bing search homepage (com.testingdocs.stock.steps.CommonSteps.java#openBing)

Matching methods as shown below:

step method 1 in BingSteps


@Given("bing search homepage")
    public void openBing()
    {
        //    This is in BingSteps.class
        System.out.println(this.getClass()+ "step method invoked");
   
    }

 

step method 2 in CommonSteps

@Given("bing search homepage")
    public void openBing()
    {

       //This is in CommonSteps.class
        System.out.println(this.getClass()+ "step method invoked");
   
    }

 

JBehave_Ambigious_Steps2

 

The above picture representation is for easy understanding the concept.

Related Posts

Serenity BDD JBehave Result Jenkins

JBehave

Running Serenity BDD stories with Jenkins

SerenityReportDebug

JBehave

Debug Serenity BDD JBehave project

Git Commit JBehave Project

JBehave

Adding Stories to JBehave project

Filtering stories JBehave Maven

JBehave

Filtering Stories in JBehave

Serenity Project Information 2

Automation, Eclipse, JBehave

Create Serenity JBehave project from command line.

Screenshot Test Step

JBehave

Running Serenity Tests

Navigation

  • Home
  • Selenium
  • JBehave
  • Questions
  • Contact
  • Privacy
  • About

Random Posts

  • List_OperationsJava List Interface Example
  • Test webpage urlTesting webpage mobile-friendliness using a tool
  • Timeout test JUnitTesting timeouts with JUnit 4
  • JUnit Jupiter APIJUnit 5 Jupiter API Annotations
  • JUnit LibraryAdding JUnit5 library to a Project
  • Serenity BDD JBehave Result JenkinsRunning Serenity BDD stories with Jenkins
  • SerenityReportDebugDebug Serenity BDD JBehave project
  • Git Commit JBehave ProjectAdding Stories to JBehave project
  • Filtering stories JBehave MavenFiltering Stories in JBehave
  • Serenity Project Information 2Create Serenity JBehave project from command line.
  • Screenshot Test StepRunning Serenity Tests
  • No goals specified Maven ErrorHow to fix Maven error No goals specified
  • Sample_Eclipse_Check_programAutomation Environment Setup Verification
  • Blue Ocean UIBlue Ocean Jenkins Plugin
  • Android Virtual Device ManagerCreating Android Virtual Device with AVD Manager
TestingDocs.com
© 2016 - 2019 TestingDocs.com All Rights Reserved
TestingDocs.com

TestingDocs.com

Links

  • Home
  • Selenium
  • JBehave
  • Questions
  • Contact
  • Privacy
  • About

Search