Skip to main content

Comment in Cucumber Feature File

A comment is fundamentally a piece of code meant for documentation purposes and not for execution. To make Feature File and Step Definition File more readable and understandable. It is essential to use comments at appropriate places in the file. The Comment also helps while debugging the code.

In Java, we have Single Line, Multi-Line, and Documentation Comment. You can use these types of comments in your step definition file because your step definition file is written in Java, but in the Feature file, we can not use all these types of comments.

How to comment in the feature file

Cucumber feature files can have comments at any place. We need to start the statement with the "#" sign to put Comments. Feature file only supports comments with a # sign. We put # at the beginning of our Comment. You want to do a single line or multiple line comments; you need to put # before all lines. The parser will ignore every line which starts with #.

How to comment multiple lines in the feature file

To comment multi-line or use block comment, select all the lines and press shortcut

  • Ctrl + / in Windows Eclipse
  • Command + / in Mac Eclipse

 Other IDE may have other shortcuts for doing this. Similarly to remove comment press Ctrl + / again.

Video Tutorial: Add Comment in Cucumber Feature File

Submitted by tgoswami on August 30, 2020

Tarun has 11+ years of experience in Quality Assurance in different domains like Banking, E-commerce, Health and Education.

About

At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.