From f4571d6e240cbfe79e52d28247ef1e4d21998269 Mon Sep 17 00:00:00 2001 From: Falko Modler Date: Sun, 2 Jan 2022 20:52:39 +0100 Subject: [PATCH] Configurable secondary orderer for `QuarkusTestProfileAwareClassOrderer` Resolves #21892 --- .../QuarkusTestProfileAwareClassOrderer.java | 65 +++++++++++++++---- ...arkusTestProfileAwareClassOrdererTest.java | 38 ++++++++++- 2 files changed, 89 insertions(+), 14 deletions(-) diff --git a/test-framework/junit5/src/main/java/io/quarkus/test/junit/util/QuarkusTestProfileAwareClassOrderer.java b/test-framework/junit5/src/main/java/io/quarkus/test/junit/util/QuarkusTestProfileAwareClassOrderer.java index 9ec802da34003..5d9c451f8908a 100644 --- a/test-framework/junit5/src/main/java/io/quarkus/test/junit/util/QuarkusTestProfileAwareClassOrderer.java +++ b/test-framework/junit5/src/main/java/io/quarkus/test/junit/util/QuarkusTestProfileAwareClassOrderer.java @@ -3,6 +3,8 @@ import java.util.Arrays; import java.util.Comparator; import java.util.Optional; +import java.util.stream.Collectors; +import java.util.stream.IntStream; import org.junit.jupiter.api.ClassDescriptor; import org.junit.jupiter.api.ClassOrderer; @@ -26,15 +28,19 @@ * after tests with profiles and Quarkus*Tests with only unrestricted resources are handled like tests without a profile (come * first). *

- * Internally, ordering is based on three prefixes that are prepended to the fully qualified name of the respective class, with - * the fully qualified class name of the {@link io.quarkus.test.junit.QuarkusTestProfile QuarkusTestProfile} as an infix (if - * present). + * Internally, ordering is based on prefixes that are prepended to a secondary order suffix (by default the fully qualified + * name of the respective test class), with the fully qualified class name of the + * {@link io.quarkus.test.junit.QuarkusTestProfile QuarkusTestProfile} as an infix (if present). * The default prefixes are defined by {@code DEFAULT_ORDER_PREFIX_*} and can be overridden in {@code junit-platform.properties} * via {@code CFGKEY_ORDER_PREFIX_*}, e.g. non-Quarkus tests can be run first (not last) by setting * {@link #CFGKEY_ORDER_PREFIX_NON_QUARKUS_TEST} to {@code 10_}. *

+ * The secondary order suffix can be changed via {@value #CFGKEY_SECONDARY_ORDERER}, e.g. a value of + * {@link org.junit.jupiter.api.ClassOrderer.ClassOrderer.Random} will order the test classes within one group randomly instead + * by class name. + *

* {@link #getCustomOrderKey(ClassDescriptor, ClassOrdererContext)} can be overridden to provide a custom order number for a - * given test class, e.g. based on {@link org.junit.jupiter.api.Tag}, class name or something else. + * given test class, e.g. based on {@link org.junit.jupiter.api.Tag} or something else. *

* Limitations: *