Open eniuane opened 3 years ago
Is this even a Quarkus issue?
I mean do regular (non-Quarkus) tests annotated with @DisplayName
show up like you mention in the reports?
Is this even a Quarkus issue?
I mean do regular (non-Quarkus) tests annotated with
@DisplayName
show up like you mention in the reports?
If I run non-Quarkus tests annotated with @DisplayName I got no problem, this only happens when its a quarkus test.
I am not seeing that. I am seeing @Display
name not being used at all in the surefire reports
I just came across some maybe related issue ...
I am not seeing that. I am seeing @Display name not being used at all in the surefire reports
The default maven-surefire-plugin
and maven-failsafe-plugin
configuration does not use the @DisplayName
annotation for the generated reports. However it is possible to configure the plugin accordingly to use the "phrased" names in reports as shown in the first post:
<configuration>
<statelessTestsetReporter
implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5Xml30StatelessReporter">
<disable>false</disable>
<version>3.0</version>
<usePhrasedFileName>false</usePhrasedFileName>
<usePhrasedTestSuiteClassName>true</usePhrasedTestSuiteClassName>
<usePhrasedTestCaseClassName>true</usePhrasedTestCaseClassName>
<usePhrasedTestCaseMethodName>true</usePhrasedTestCaseMethodName>
</statelessTestsetReporter>
</configuration>
Is this even a Quarkus issue?
This is not really a Quarkus issue imho. However Quarkus uses in almost every test-related tutorial the example of writing a @QuarkusMainTest
and then write an integration test for the native build by simply extending the test and annotate it with @QuarkusMainIntegrationTest
:
@QuarkusMainTest
public class DemoTest {
@Test
public void givenSome_whenAction_theExpectOther() {
Assertions.assert(other);
}
}
@QuarkusMainIntegrationTest
public class DemoIT extends DemoTest {}
As soon as somebody annotates the test with @DisplayName
he/she might expect this DisplayName to be used in the integration test too. But @DisplayName
is not inherited.
Perhaps Quarkus could reduce the irritations by providing a DisplayNameGenerator
that inspects super classes for given @DisplayName
annotations and uses them if found for the integration test.
An incomplete example for such a DisplayNameGenerator is:
import java.lang.reflect.Method;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.DisplayNameGenerator;
public class InheritedDisplayNameDisplayNameGenerator extends DisplayNameGenerator.Standard {
@Override
public String generateDisplayNameForMethod(Class<?> testClass, Method testMethod) {
if (testMethod.isAnnotationPresent(DisplayName.class)) {
return super.generateDisplayNameForMethod(testClass, testMethod);
}
Class<?> clazz = testClass;
while (testClass.getSuperclass() != null) {
Method[] methods = clazz.getMethods();
for (Method method : methods) {
if (method.getName().equals(testMethod.getName())
&& method.isAnnotationPresent(DisplayName.class)) {
return method.getAnnotation(DisplayName.class).value();
}
}
}
return super.generateDisplayNameForMethod(testClass, testMethod);
}
}
In addition @QuarkusMainIntegrationTest
could be extended to use this DisplayNameGenerator per default (but I'm not sure whether this should be a default behaviour):
@Target(ElementType.TYPE)
@ExtendWith({ QuarkusMainIntegrationTestExtension.class })
@DisplayNameGeneration(InheritedDisplayNameDisplayNameGenerator.class)
@Retention(RetentionPolicy.RUNTIME)
public @interface QuarkusMainIntegrationTest {
}
Btw: Perhaps worth considering: @DisplayNameGeneration
is inherited
Describe the bug Quarkus is not using the @DisplayName configured on the integration tests in the report generated by failsafe report.
Expected behavior when running mvnw verify failsafe:integration-test failsafe:verify
the @DisplayName should appear in the testcase name on the report.
Actual behavior testcase name is currently the method name.
Configuration
POM.xml
Example of test java class:
Screenshots
Failsafe report .xml
Environment (please complete the following information): java -version openjdk version "11.0.9.1" 2020-11-04 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9.1+1) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.9.1+1, mixed mode)
Quarkus version is 1.9.1.Final
mvnw --version Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: C:\Users\user.m2\wrapper\dists\apache-maven-3.6.3-bin\39u95cbq5nt4o0nbmqmiptki14\apache-maven-3.6.3 Java version: 11.0.9.1, vendor: AdoptOpenJDK, runtime: C:\Program Files\AdoptOpenJDK\jdk-11.0.9.101-hotspot Default locale: en_US, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Failsafe and Surefire version is 3.0.0-M5
Additional context (Add any other context about the problem here.)