-
-
Notifications
You must be signed in to change notification settings - Fork 612
Description
If a Scenario has multiple Examples tables, these are executed correctly. However, the pretty printer outputs as though they were in a single table, losing any table titles and rendering inconsistent column padding. For example, a feature like:
Scenario: Grouped examples
When I input <name>
Then I should see <result>
Examples: valid cases
| name | result |
| Bob | Hi Bob |
| Jenny | Hi Jenny |
Examples: invalid cases
| name | result |
| 123456 | "123456" doesn't look like a name? |
| Brian | Sorry Brian, you're banned |will output like:
Scenario: Grouped examples # features/test.feature:6
When I input <name> # FeatureContext::input()
Then I should see "<result>" # FeatureContext::assertSee()
Examples:
| name | result |
| Bob | Hi Bob |
| Jenny | Hi Jenny |
| 123456 | '123456' doesn't look like a name? |
| Brian | Sorry Brian, you're banned |
This is because Behat uses the original Behat/Gherkin API to fetch OutlineNode::getExamples() and OutlineNode::getExampleTable(). When Behat/Gherkin added support for parsing multiple tables, a new API was added for fetching the tables separately and the pre-existing methods were updated to convert the parsed data into a single array of ExampleNode and a single ExampleTableNode to avoid any BC impact.
This works for our test runner, and means that all the information the formatters display about individual examples (including the line numbers in the file) are correct.
However, printing separate headings and correctly padding the columns would require updating the pretty printer to use the new Behat/Gherkin API to fetch the original parsed nodes rather than the modified copies from the BC layer.
It may also need refactoring to the pretty printer's event handling - currently the PrettyOutlinePrinter renders the start of the outline during the BeforeOutlineTested event. This includes the header of the examples table, with the assumption that there is only one. The PrettyExampleRowPrinter then prints the individual table rows after each scenario / example is tested. From an initial review of the code, my hunch is that it will be tricky to update this to render separate table headings without a BC break in those classes.
We could potentially consider this for 4.0, or perhaps mark the various individual printer classes that the pretty printer uses as @internal to allow us to make breaking changes to them later in the 4.x series.