ducminh-phan / reformat-gherkin

Formatter for Gherkin language
MIT License
24 stars 13 forks source link

Commented Examples table row #55

Open Frame42 opened 2 years ago

Frame42 commented 2 years ago

Describe the bug

When reformatting files with Examples table rows commented out, the lines are moved with the next scenario instead of being kept with the table. Is this the expected behavior ?

Example input

  Scenario Outline: ScenarioA
    Given something

    @group_A
    Examples:
      | from | to |
      | 0    | 0  |
      | 0    | 1  |
      | 0    | 2  |
      | 1    | 1  |
      | 2    | 0  |
      | 1    | 0  |
      | 2    | 1  |
      | 0    | 2  |

    @group_B
    Examples:
      | from | to |
      | 0    | 0  |
#      | 0    | 1  |
#      | 0    | 2  |
      | 1    | 1  |
      | 2    | 0  |
#      | 1    | 0  |
#      | 2    | 1  |
#      | 0    | 2  |

  @TAG2
  Scenario Outline: Next Test

Expected behaviour

  Scenario Outline: ScenarioA
    Given something

    @group_A
    Examples:
      | from | to |
      | 0    | 0  |
      | 0    | 1  |
      | 0    | 2  |
      | 1    | 1  |
      | 2    | 0  |
      | 1    | 0  |
      | 2    | 1  |
      | 0    | 2  |

    @group_B
    Examples:
      | from | to |
      | 0    | 0  |
      # | 0    | 1  |
      # | 0    | 2  |
      | 1    | 1  |
      | 2    | 0  |
      # | 1    | 0  |
      # | 2    | 1  |
      # | 0    | 2  |

  @TAG2
  Scenario Outline: Next Test

Actual behaviour

    Given something

    @group_A
    Examples:
      | from | to |
      | 0    | 0  |
      | 0    | 1  |
      | 0    | 2  |
      | 1    | 1  |
      | 2    | 0  |
      | 1    | 0  |
      | 2    | 1  |
      | 0    | 2  |

    @group_B
    Examples:
      | from | to |
      | 0    | 0  |
      # | 0    | 1  |
      # | 0    | 2  |
      | 1    | 1  |
      | 2    | 0  |

  # | 1    | 0  |
  # | 2    | 1  |
  # | 0    | 2  |
  @TAG2
  Scenario Outline: Next Test

Environment

ducminh-phan commented 2 years ago

@Frame42 This is the expected behaviour. There is no (simple) way to know that the commented lines are commented table rows. As a workaround, you can have a non-commented table row after the commented ones. For example

  Scenario Outline: ScenarioA
    Given something

    @group_B
    Examples:
      | from | to |
      | 0    | 0  |
      # | 0    | 1  |
      # | 0    | 2  |
      | 1    | 1  |
      # | 1    | 0  |
      # | 2    | 1  |
      # | 0    | 2  |
      | 2    | 0  |