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

Use feature parameterized name for example display name #2743

Closed
betty-domain opened this issue Apr 28, 2023 · 6 comments · Fixed by #2860
Closed

Use feature parameterized name for example display name #2743

betty-domain opened this issue Apr 28, 2023 · 6 comments · Fixed by #2860
Assignees
Labels
🙏 help wanted Help wanted - not prioritized by core team ⚡ enhancement Request for new functionality

Comments

@betty-domain
Copy link

betty-domain commented Apr 28, 2023

🤔 What's the problem you're trying to solve?

When I'm using junit4 to run my cucumber test, I can parameterized my feature scenario outline name and it was complete before execution phase to create X scenarios where display name was corresponding feature nawe with corresponding parameters value
Now i'm using junit-platform-engine and my example are executed with name "Example #1, Example #2..." so i'm loosing functional information about what my test is doing

Example :

Feature file :
Scenario Outline : My Contract with option
Given a contract with option
When I want to show it
Then I see the name of Contract

 Examples:
   | codeOption | contractName  |
   | '01'               | 'Contract A'     |
   | '02'               | 'Contract B'     |
   | '03'               | 'Contract C'     |

When using Junit4 I can see in execution tests details :

  • My Contract with option '01' : Passed
  • My Contract with option '02' : Passed
  • My Contract with option '03' : Failed

Now using Junit platform Engine (Junit5) I can see in execution tests details :

  • My Contract with option 'codeOption'
    • Examples
      • Example 1 : Passed
      • Example 2 : Passed
      • Example 3 : Failed

I don't know with business case is failed, I have to open the feature file and to count examples to find which one failed.

✨ What's your proposed solution?

Reuse junit4 mechanism to use parameterized display name if parameters are found in scenaio outline name

⛏ Have you considered any alternatives or workarounds?

I haven't find a workaround for the moment

📚 Any additional context?

@mpkorstanje mpkorstanje added ⚡ enhancement Request for new functionality 🙏 help wanted Help wanted - not prioritized by core team and removed 🙏 help wanted Help wanted - not prioritized by core team labels Apr 28, 2023
@mpkorstanje
Copy link
Contributor

mpkorstanje commented Apr 29, 2023

I would welcome a PR that adds two properties:

cucumber.junit-platform.naming-strategy.short.example-name=pickle-name|example-number
cucumber.junit-platform.naming-strategy.long.example-name=pickle-name|example-number

Then given the feature:

Feature: Examples Tables

  Scenario Outline: Eating <eat> of <start> cucumbers 
    Given there are <start> cucumbers
    When I eat <eat> cucumbers
    Then I should have <left> cucumbers

    Examples: These are passing
      | start | eat | left |
      |    12 |   5 |    7 |
      |    20 |   5 |   15 |

    Examples: These are failing
      | start | eat | left |
      |    12 |  20 |    0 |
      |     0 |   1 |    0 |

When the cucumber.junit-platform.naming-strategy.short.example-name=example-number is used this should be rendered as:

 * Example Tables
   *  Eating <eat> of <start> cucumbers 
     * These are passing
       * Example #1.1
       * Example #1.2
     * These are failing
       * Example #1.1
       * Example #1.2

When the cucumber.junit-platform.naming-strategy.short.example-name=pickle-name is used this should be rendered as:

 * Example Tables
   *  Eating <eat> of <start> cucumbers 
     * These are passing
       * Eating 5 of 12 cucumbers 
       * Eating 5 of 20 cucumbers 
     * These are failing
       * Eating 20 of 12 cucumbers 
       * Eating 1 of 0 cucumbers 

This can be implemented by changing the DefaultNamingStrategy. For inspiration on how to do this please have a look at the org.junit.platform.engine.support.hierarchical.DefaultParallelExecutionConfigurationStrategy from JUnit 5.

@mpkorstanje mpkorstanje added the 🙏 help wanted Help wanted - not prioritized by core team label Apr 29, 2023
@maestro-game
Copy link
Contributor

maestro-game commented Mar 9, 2024

Hi everyone. I'd like to solve this issue by contributing to this awesome project which I'm using daily at work. Just have started working and informing in case of other people working on this issue

@mpkorstanje
Copy link
Contributor

Cheers! All yours.

@fslevoaca-ionos
Copy link

Inside Intellij Idea these examples are still shown as numbers instead of picke names. But I believe this might be related to Intellij Idea itself or Cucumber for Java plugin

@mpkorstanje
Copy link
Contributor

mpkorstanje commented Apr 19, 2024

That will depend on how you run Cucumber. IDEA uses the io.cucumber.core.cli.Main with the TeamCityPlugin. If you run the @Suite annotated class you'll get the parametrized name.

You could create a new issue for the TeamCityPlugin but we don't have the ability to provide configuration for indivual plugins. That will require a serious refactoring. So it is unlikely that this will happen in the short term.

@fslevoaca-ionos
Copy link

fslevoaca-ionos commented Apr 19, 2024

Yeah I know.
If you run the @Suite annotated class you'll get the parametrized name. Almost no one runs it like that inside Idea :)
While using Idea, it means that you are in the development phase of the tests, thus you run them one by one while implementing them. Just like writing any code.
Right click inside feature file -> Run Scenario is the best and most common approach.

I will open an issue for the TeamCity plugin.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙏 help wanted Help wanted - not prioritized by core team ⚡ enhancement Request for new functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants