-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scenario (outline) title and placeholders #270
Comments
Just to add a bit more context / background: Suffixing with index numbersThe numbering of scenarios that @uuf6429 is actually only true for the JUnit formatter in Behat (and perhaps third-party ones). The progress printer does not display any naming etc for the Scenario Outline / Examples unless it fails. For failing Examples, it produces output like:
Note that the title / text of the scenario outline is not displayed at all. The pretty printer always prints the full Scenario Outline and Examples table. If everything passes, this is all rendered green. If examples fail then the failure is rendered inline below the failed row in the table, like so: Flattening Scenario and Scenario OutlineAlthough In #253 the cucumber/gherkin AST is still being parsed back to our Behaviour of
|
Given all that, I think my proposal would be:
On numbering, I'd suggest:
This means a tiny bit more verbosity in cases where the scenario titles are already unique, but saves any complexity of trying to work out whether there are duplicates and how to number them if so. So:
What do others think - @uuf6429 @carlos-granados @ttomdewit? |
In general, this looks really good. My only question would be about the |
I'm also unsure about Appending the number in all cases feels a bit not ideal, but it's perhaps the only practical solution. Keep in mind that the scenario titles will never be unique anyway - a different scenario can always define the same title (in which case the "row number" wouldn't help anyway). On the whole the proposal looks fine though. |
Yeah, |
I'm fine either way, your explanation for row makes sense too. |
Well just because we should make a decision, let's go |
If the pretty formatter of Behat is a blocker for moving to a pickle-like API (removing the difference between scenarios and outlines at execution time, which also makes it easier to properly handles |
Not opposed to that, but that feels like it would have to be for a (potentially quite big) Behat 4.x and meanwhile IMO there's a case for a smaller backward-compatible enhancement to allow us to fix Behat/Behat#1448 and potentially other cases where it's currently hard to get a "scenario name" for an example in 3.x. |
In this PR, we toyed with the idea of having placeholders in scenario outline titles.
Why did this come up?
Currently, we distinguish between scenarios (aka "examples") of a scenario outline by appending a number to the title. This causes a problem when specific examples are rerun - if you rerun all examples except the first, the first example that is ran will be suffixed with
" #1"
even though it is actually the 2nd example in the feature file.Conceptually it is actually the first, but in practice, that's not useful to users. See: Behat/Behat#1448
Options
Passing <input> results in <output>
:Results in <result>
:Apparently, option 3 is already implemented in cucumber, and has been requested in the past.
Open Questions (for Option 3)
Should we expose placeholder replacement in
ExampleNode
? As a behat user, I would have found that useful in the past, as a behat contributor, it would have been useful in Display outline values instead of index in junit output Behat#1459.We have
getTitle
andgetOutlineTitle
. What would be the best way to implement placeholder replacement? My current opinion:getTitle
- this feels like it should return the definitive title, e.g. to be shown in reports and so on. In the ideal world, I think this should be the one replacing placeholders and adding numbers for deduplication.getOutlineTitle
- Internally (e.g. even in gherkin), it seems that there shouldn't be a concept of a scenario outline - instead they should be flattened into regular scenarios. With that in mind, I think the "outline title" should be the original (parent?) title - since that parent is the "scenario outline".getOutlineTitleWithPlaceholders
(additional method) - I would go for such a method if we want to be absolutely BC safe. That said, I do feel that the majority of end users would rather have the BC break than the current approach, but that's my hypothesis.It's important to note that
getTitle
is already used extensively and changing it might break things.Not a question per se, but we're considering numbering repeated titles, this would preserve the past behaviour and avoid duplication given titles with missing placeholders.
@acoulton On point 2, this approach could work, but I'm not too fond of it:
The text was updated successfully, but these errors were encountered: