cucumber / cucumber-jvm

Cucumber for the JVM
https://cucumber.io
MIT License
2.7k stars 2.02k forks source link

Ability to name the hooks in Java #2917

Open andytangclearme opened 2 months ago

andytangclearme commented 2 months ago

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

Previous closed issue: https://github.com/cucumber/messages/issues/73

The issue is four years old and closed, but the java hook annotations still does not accept name as a property.

✨ What's your proposed solution?

Update the hook annotations (@Before, @After, etc.) to have name property:

@Before(name = "Take out the rubbish")
public void doSomething(){
    // Do something before each scenario
}

⛏ Have you considered any alternatives or workarounds?

No response

📚 Any additional context?

Intellij JUnit5 output:

image
mpkorstanje commented 2 months ago

The issue is four years old and closed, but the java hook annotations still does not accept name as a property.

Would you be interested in providing a pull request?

If so please take note of https://github.com/cucumber/cucumber-jvm/issues/2798#issuecomment-2067055712. The hook names can be emitted in messages and the html report should render them. But formatters that aren't messages based won't have access just yet.

Also note that the output in IDEA should include the hooks method name after https://github.com/cucumber/cucumber-jvm/pull/2881. You may want to update Cucumber.