Comment is basically a piece of code meant for documentation purpose and not for execution. To make Feature File and Step Definition File more readable and understandable. It is important to use comments at appropriate places in the file. This also helps while debugging the code.
Cucumber feature files can have comments at any place. To put comments, we just need to start the statement with “#” sign. Feature file only support comments with # sign. You need to put # at beginning of your comment. You want to do single line or multiple comment you need to put # before all lines. Parser will ignore every line which start with #.
To comment multi line or use block comment select all the line and press Ctrl + / in PhpStorm. Other IDE may have other shortcuts for doing this. Similarly to remove comment press Ctrl + / again.
Below is the example:
#This is sample scenario
#It use several gherkin keyword and tag
@tag1
Scenario: Title of your scenario
Given I want to write a step with precondition
And some other precondition
When I complete action
And some other action
And yet another action
Then I validate the outcomes
And check more outcomes
In above code first 2 lines are comments.
In PHP we have Single Line and Multi Line Comments, you can use these types of comments in your step definition file because your step definition file is written in PHP, click here to know how to write comments in PHP.
Note: the comment block starts with /**, and not the usual /*. This is important for Behat to be able to parse such comments as annotations!