I'm submitting a ...
What is the current behavior?
With Junit5 it is possible to use Display name generators to improve test names automatically.
Allure-junit5 is supposed to print suite/test names from displayName value if it is available. While it works correctly for methods (testIdentifier.getDisplayName() is used), it does not work for classes (@DisplayName annotation value is looked, so values from name generator are ignored).
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
- Using junit5 + allure, set up DisplayNameGenerator like next:
MyDisplayNameGenerator.java
import java.lang.reflect.Method;
import org.junit.jupiter.api.DisplayNameGenerator;
public class MyDisplayNameGenerator implements DisplayNameGenerator {
@Override
public String generateDisplayNameForClass(Class<?> testClass) {
return "le test suite";
}
@Override
public String generateDisplayNameForNestedClass(Class<?> nestedClass) {
return "nested class";
}
@Override
public String generateDisplayNameForMethod(Class<?> testClass, Method testMethod) {
return "test method";
}
}
- Apply it to test:
MyTest.java
import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
@DisplayNameGeneration(MyDisplayNameGenerator.class)
public class MyTest {
@Test
void testSomething() {}
@Nested
class NestedClass {
@Test
void testAnotherThing() {}
}
}
- Execute test & generate allure report

execution in IDEA to prove that generator works as expected

generated Allure report
What is the expected behavior?
Allure should get displayed class/nested class name from provided DisplayNameGenerator
What is the motivation / use case for changing the behavior?
- Make test maintenance easier (I can supply single
DisplayNameGenerator which will turn class or method names into human-readable sentences for example, and do not use @DisplayName annotations; or even apply whatever complex custom mechanizm);
- Improve allure-junit5 integration (I would like to leverage junit5 capabilities to improve my allure experience)
Please tell us about your environment:
| Allure version |
2.13.7 |
| Test framework |
junit5@5.7.0 |
| Allure integration |
allure-junit5@2.13.7 |
| Generate report using |
allure-gradle@2.8.1 |
Other information
N.B. Maybe it is worthy to provide, along with fix, some mechanism that will provide human-readable class/method names by default (controlled by some allure property)? IMHO it could be useful to prettify report for all the existing tests by 1 property enabled if no displayName provided in tests (in any way - annotations/ generators etc).
I'm submitting a ...
What is the current behavior?
With Junit5 it is possible to use Display name generators to improve test names automatically.
Allure-junit5 is supposed to print suite/test names from
displayNamevalue if it is available. While it works correctly for methods (testIdentifier.getDisplayName()is used), it does not work for classes (@DisplayNameannotation value is looked, so values from name generator are ignored).If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
MyDisplayNameGenerator.java
MyTest.java
execution in IDEA to prove that generator works as expected
generated Allure report
What is the expected behavior?
Allure should get displayed class/nested class name from provided
DisplayNameGeneratorWhat is the motivation / use case for changing the behavior?
DisplayNameGeneratorwhich will turn class or method names into human-readable sentences for example, and do not use@DisplayNameannotations; or even apply whatever complex custom mechanizm);Please tell us about your environment:
Other information
N.B. Maybe it is worthy to provide, along with fix, some mechanism that will provide human-readable class/method names by default (controlled by some allure property)? IMHO it could be useful to prettify report for all the existing tests by 1 property enabled if no
displayNameprovided in tests (in any way - annotations/ generators etc).