Skip to content
This repository was archived by the owner on May 28, 2019. It is now read-only.
This repository was archived by the owner on May 28, 2019. It is now read-only.

Pretty formatter cannot handle comments in feature correctly #347

Description

@xuanzhaopeng

Description:

When there are several comments in feature file, which contains one scenario outline, the pretty formatter cannot handle it correctly.

Stack Trace:

java.lang.StringIndexOutOfBoundsException: String index out of range: -2
    at java.lang.String.substring(String.java:1954)
    at gherkin.formatter.StepPrinter.writeStep(StepPrinter.java:11)
    at gherkin.formatter.PrettyFormatter.printStep(PrettyFormatter.java:259)
    at gherkin.formatter.PrettyFormatter.printSteps(PrettyFormatter.java:130)
    at gherkin.formatter.PrettyFormatter.replay(PrettyFormatter.java:121)
    at gherkin.formatter.PrettyFormatter.scenario(PrettyFormatter.java:98)

How to reproduce :

Feature : My feature

comments 1

comments 2

Scenario Outline : My scenaroi called
Given I do sth1
# comment
When I do sth2
# comment
Then I do sth3

Examples:
# comment here
| Arg1 | Name |
# comment here
# comment here
| Val1 | Val2 |
# comment here

Guess :

I follow the step from Cucumber-jvm to gherkin2, I found the problems seems could be located in PrettyFormatter.replay() , maybe in more detail, it is located in PrettyFormatter.addAnyOrphanMatch()

If I get deep debug information, I will let u all know

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions