3

I need to comment multiple lines while debugging test cases. single line i can comment using # but I am looking for block comments.

example:

create integration using Doc input

* def result = call read('classpath:ic/common/resources/integration/createIntegration.feature') { X-CSRF-TOKEN: csrfToken, JSESSIONID: jsessionid, integrationName: Add21NumDocInputs, id: tenantID, inputFile: 'ic/common/resources/integration/createIntegrationAdd2NumDocInputs.json'}

Then match result.responseStatus contains 201

Then match result.response.integration.message.description contains 'Success'

Then match result.response.integration.serviceData.message contains 'Add21NumDocInputs' +' created successfully'

Community
  • 1
  • 1
Anupama
  • 391
  • 4
  • 16

2 Answers2

3

The Gherkin syntax does not support block-comments, but here is what most teams do.

Use the Cucumber IDE integration - supported in Eclipse, IntelliJ, Visual Studio Code etc.

For example, if you use Eclipse, CTRL + / will comment all selected lines.

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
-2

In Gherkin, """ """ can comment the block of the code. But for Karate, it would be just a block.

The below portion is taken as a comment when it is immediate after a Scenario.

    Scenario: Testing commenting multiple lines
    """ some block comment
      still block comment
  """ end of block comment
      Given url 'https://testurl.com'
      When method GET
      Then status 200
      And print response
      And print "This is the first line"
      #----> You can only commnent this way
      #          And print "This is the second line"
      #          And print "This is the Third line"
      #          And print "This is the Forth line"
      #          And print "This is the fifth line"          
      And print "This is the sixth line"

There is a wide discussion on this and we can achieve a nearer solution by configuring the IDE. Check the solution here.

How to do block comments in Gherkin?

Maaza
  • 79
  • 1
  • 1
  • 8
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 01 '21 at 04:47