Skip to content

docstrings

Tyler-Keith-Thompson edited this page Dec 1, 2019 · 1 revision

Docstrings

Docstrings in Gherkin are multi-line string literals with an optional content type. They can use """ or ``` as indicators.

Feature: DocString variations

  Scenario: minimalistic
    Given a DocString with content type
      """xml
      <foo>
        <bar />
      </foo>
      """

In this example there's a Docstring with a content type of xml. You can access this on the step object like this:

Given("a DocString with content type") { _, step in
    step.docString?.literal //<foo>\n    <bar />\n</foo>
    step.docString?.contentType //xml
}