how to comment multiple lines in karate?

Viewed 4442

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'

2 Answers

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.

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

I could achieve the same as follows and the below lines were commented.

"""
    /*
     And match response.messageTraceId == (#number)
     And match response.messageTraceId != (null)
     And match response.currentBalance != (null)
     And match response.availBalance != (null)
    */
"""

I see that more folks are using the following way

How to do block comments in Gherkin?

Related