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

PrettyFormatter options #331

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

muhqu
Copy link

@muhqu muhqu commented Feb 17, 2015

This PR adds 3 optional formatting options to the PrettyFormatter. All options default to false to not change the formatting result unless explicitly enabled.

right-align numeric values in tables

formatter.setRightAlignNumericValues(true);
  Scenario: Format beautifully right-aligned numbers in a data table
    When I have this table:
      | name                          | value  |
      | barel of extra long cucumbers | 129.95 |
      | extra long cucumber           |  10.95 |
      | tiny cucumber                 |   2.95 |

center-align step keywords

formatter.setCenterSteps(true);
  Scenario: Format beautifully center-aligned steps
    Given there are 12 cucumbers
     When I eat 3 cucumbers
      And I throw 2 cucumbers into the trash can
     Then I should have 7 cucumbers

preserve a single blank line between steps

formatter.setPreserveBlankLineBetweenSteps(true);
  Scenario: Repetitive when.. then..
    Given there are 12 cucumbers
    When I eat 3 cucumbers
    Then I should have 9 cucumbers

    When I eat 2 cucumbers
    Then I should have 7 cucumbers

    When I eat 1 cucumbers
    Then I should have 6 cucumbers

e.g.
      | title             | traded      | effective   |
      | Required Forecast |    53781.89 |    53781.89 |
      | Eligible Forecast | 10756437.88 | 10756437.88 |
e.g.
|   Given I have ...
|    When I do ...
|     And I do ...
|    Then I should ...
e.g.
|    Given there are 12 cucumbers
|    When I eat 3 cucumbers
|    Then I should have 9 cucumbers
|
|    When I eat 2 cucumbers
|    Then I should have 7 cucumbers
|
|    When I eat 1 cucumbers
|    Then I should have 6 cucumbers
@muhqu
Copy link
Author

muhqu commented Mar 13, 2015

@aslakhellesoy any chance to get this one merged?

It would be great to get this into a release so I don't have to make a copy of the PrettyFormatter.java in cucumber/cucumber-eclipse#107.

@aslakhellesoy
Copy link
Contributor

Probably not I'm afraid. We're focussing on Gherkin 3 now: https://groups.google.com/d/msg/cukes/YLKsqbBMBoI/KR_Zq6DBgJwJ

We'll move the formatting to Cucumber - I'll keep this in mind when we get there. I've been wanting the same thing myself!

@muhqu
Copy link
Author

muhqu commented Mar 13, 2015

@aslakhellesoy oh, hm k. …maybe I can contribute to Gherkin 3 as well. I've written a gherkin parser in golang.

@aslakhellesoy
Copy link
Contributor

@muhqu oh that would be fantastic! Let me know if anything is missing from the contribution guide!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants