Hire QA – Specialized in QA Recruitment, Technical Interviews and Testing Solutions

How To Comment On The Cucumber Framework?

Category: BDD Cucumber

We can add comments in the Cucumber code. The comments are incorporated in code mostly for documentation and not for including program logic. It makes the code easier to apprehend and to debug the errors. Also, comments can be put at any point in the code.

Inside the feature file, the comments are added after the (#) symbol and the step definition contains comments after the (//) symbol.

Feature file with comments.

  • Feature: Customer verification
  • # Scenario with customer
  • Scenario: Verify customer details
  • Given User navigates to Customer Information Page
import cucumber.api.java.en.Given;
public class CustomerInformation {
 
@Given ("^User navigates to Customer Information Page$")
//method to map @Given scenario in feature file
public void navigate_to_customerInformation () {
      System.out.println ("Customer Information Page is navigated");
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *