Skip to content
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

Enhancement of #scenarioNameTemplate for scenario outlines #250

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pvoisin
Copy link

@pvoisin pvoisin commented Jul 25, 2024

Today, given a scenario outline containing multiple scenarios, #scenarioNameTemplate (available as an option) would always be called once before the first scenario is even touched. Then, iteratively, for every scenario, it would not be called again at all. So, proposed changes include :

  • Not calling #scenarioNameTemplate once before scenarios are actually iterated over;
  • Call it after for every scenario in the outline;
  • Passing feature, scenario and outline to the function for better control over the title it can produce (here, I only needed the ParsedScenario instance but since the other two are available they might be useful sometimes too).

Example feature:

Feature: Number Utility

  Scenario Template: with number <NUMBER> (<PRECISION>) → <RESULT>
    Given number <NUMBER>
    And precision <PRECISION>
    When #round is called
    Then result should be <RESULT>

    Examples:
      | NUMBER            | RESULT      | PRECISION |
      |             0.000 |           0 |           |
      |             1.255 |        1.26 |         2 |
      ...

For every scenario/example, scenarioTitle is today "with number <NUMBER> (<PRECISION>) → <RESULT>".
With proposed changes, this doesn't change but the actual scenario/example's title is reachable with scenario.title (which is, for example, "with number 0.000 () → 0" for the first scenario). FYI my name template is as follows:

scenarioNameTemplate: (variables) =>
      variables.scenarioTitle.replace('() →', '→'),

@pvoisin
Copy link
Author

pvoisin commented Aug 1, 2024

Hey @bencompton! Did you have a chance to check this out?

Copy link

github-actions bot commented Oct 1, 2024

This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale label Oct 1, 2024
@pvoisin
Copy link
Author

pvoisin commented Oct 4, 2024

@bencompton - Ping! ^^

@github-actions github-actions bot removed the Stale label Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant