allure-java icon indicating copy to clipboard operation
allure-java copied to clipboard

to pass Description, name information to test results labels for fixtures

Open plagov opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe. Currently, fixtures (methods marked with @Before and @After annotations) in Cucumber JVM tests don't have support to add a human-readable name to be shown in the Allure Report. Now, those methods are shown as follows, which is not user friendly at all: image

Describe the solution you'd like An optimal solution would be to be able to put an annotation @Step on the fixture method. For example:

@Step("Attach scenario logs")
@After
public void attachLogs() {}

And then show the value of the @Step annotation in the report instead of the package and method name as it is now.

plagov avatar May 17 '22 06:05 plagov

@baev @cheshi-mantu it's been nearly 1.5y since this feature request was made. Any updates or plans you could share?

plagov avatar Oct 11 '23 21:10 plagov

Hook names are provided as strings by cucumber. We cannot access the method via reflection (or in some other way) to extract annotations.

I suggest you create a feature request for the cucumber itself. We'll be happy to support whatever solution they suggest.

However, you can change the hook names via the Allure Lifecycle API:

@Before("@hooks")
public void before() {
    Allure.getLifecycle().updateFixture(hook -> hook.setName("Human readable before name"));
    // do something
}

PS make sure to use the latest available version (2.26.0)

baev avatar Mar 18 '24 15:03 baev