diff --git a/test-framework/common/src/main/java/io/quarkus/test/common/TestResourceManager.java b/test-framework/common/src/main/java/io/quarkus/test/common/TestResourceManager.java index d9bca8af65bb9..144c987aaaf44 100644 --- a/test-framework/common/src/main/java/io/quarkus/test/common/TestResourceManager.java +++ b/test-framework/common/src/main/java/io/quarkus/test/common/TestResourceManager.java @@ -1,7 +1,7 @@ package io.quarkus.test.common; import static io.quarkus.test.common.TestResourceScope.GLOBAL; -import static io.quarkus.test.common.TestResourceScope.MATCHING_RESOURCE; +import static io.quarkus.test.common.TestResourceScope.MATCHING_RESOURCES; import static io.quarkus.test.common.TestResourceScope.RESTRICTED_TO_CLASS; import java.io.Closeable; @@ -539,7 +539,7 @@ public static boolean testResourcesRequireReload(Set } private static Set onlyMatchingResourceItems(Set set) { - return set.stream().filter(i -> i.scope == MATCHING_RESOURCE).collect( + return set.stream().filter(i -> i.scope == MATCHING_RESOURCES).collect( Collectors.toSet()); } @@ -848,7 +848,7 @@ public TestResourceClassEntry produce(AnnotationInstance annotation) { @Override public TestResourceScope scope(AnnotationInstance annotation) { - TestResourceScope scope = MATCHING_RESOURCE; + TestResourceScope scope = MATCHING_RESOURCES; AnnotationValue restrict = annotation.value("scope"); if (restrict != null) { scope = TestResourceScope.valueOf(restrict.asEnum()); diff --git a/test-framework/common/src/main/java/io/quarkus/test/common/TestResourceScope.java b/test-framework/common/src/main/java/io/quarkus/test/common/TestResourceScope.java index 3ed851576a72f..bf81a94eae5f2 100644 --- a/test-framework/common/src/main/java/io/quarkus/test/common/TestResourceScope.java +++ b/test-framework/common/src/main/java/io/quarkus/test/common/TestResourceScope.java @@ -10,16 +10,27 @@ public enum TestResourceScope { */ /** - * Means that Quarkus will run the test in complete isolation, i.e. it will restart every time it finds such a resource + * Means that Quarkus will run the test in complete isolation, i.e. it will restart every time it finds such a resource. + *

+ * Restarting Quarkus for this test means that the test resources will be restarted. + * This includes the global test resources and the Dev Services. + *

+ * Use with caution as it might slow down your test suite significantly. */ RESTRICTED_TO_CLASS, + /** - * Means that Quarkus will not restart when running consecutive tests that use the same resource + * Means that Quarkus will not restart when running consecutive tests that use the same set of resources. + *

+ * Note that when a restart is needed, all the resources will be restarted. + * This includes the global test resources and the Dev Services. + *

+ * Quarkus groups the tests by test resources to reduce the number of restarts. */ - MATCHING_RESOURCE, + MATCHING_RESOURCES, /** - * Means the resource applies to all tests in the testsuite + * Means the resource applies to all tests in the test suite. */ GLOBAL } diff --git a/test-framework/common/src/main/java/io/quarkus/test/common/WithTestResource.java b/test-framework/common/src/main/java/io/quarkus/test/common/WithTestResource.java index b6dd17854f9a8..f242723bffcf4 100644 --- a/test-framework/common/src/main/java/io/quarkus/test/common/WithTestResource.java +++ b/test-framework/common/src/main/java/io/quarkus/test/common/WithTestResource.java @@ -63,10 +63,10 @@ /** * Defines how Quarkus behaves with regard to the application of the resource to this test and the test-suite in general. - * The default is {@link TestResourceScope#MATCHING_RESOURCE} which means that if two tests are annotated with the same + * The default is {@link TestResourceScope#MATCHING_RESOURCES} which means that if two tests are annotated with the same * {@link WithTestResource} annotation, no restart will take place between tests. */ - TestResourceScope scope() default TestResourceScope.MATCHING_RESOURCE; + TestResourceScope scope() default TestResourceScope.MATCHING_RESOURCES; @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) diff --git a/test-framework/common/src/test/java/io/quarkus/test/common/TestResourceManagerReloadTest.java b/test-framework/common/src/test/java/io/quarkus/test/common/TestResourceManagerReloadTest.java index 94808bf0b17fb..97b70119a1ba8 100644 --- a/test-framework/common/src/test/java/io/quarkus/test/common/TestResourceManagerReloadTest.java +++ b/test-framework/common/src/test/java/io/quarkus/test/common/TestResourceManagerReloadTest.java @@ -38,38 +38,38 @@ public void sameSingleRestrictedToClassResource() { @Test public void sameSingleMatchingResource() { assertFalse(testResourcesRequireReload( - Set.of(new TestResourceComparisonInfo("test", MATCHING_RESOURCE)), - Set.of(new TestResourceComparisonInfo("test", MATCHING_RESOURCE)))); + Set.of(new TestResourceComparisonInfo("test", MATCHING_RESOURCES)), + Set.of(new TestResourceComparisonInfo("test", MATCHING_RESOURCES)))); } @Test public void differentSingleMatchingResource() { assertTrue(testResourcesRequireReload( - Set.of(new TestResourceComparisonInfo("test", MATCHING_RESOURCE)), - Set.of(new TestResourceComparisonInfo("test2", MATCHING_RESOURCE)))); + Set.of(new TestResourceComparisonInfo("test", MATCHING_RESOURCES)), + Set.of(new TestResourceComparisonInfo("test2", MATCHING_RESOURCES)))); } @Test public void sameMultipleMatchingResource() { assertFalse(testResourcesRequireReload( Set.of( - new TestResourceComparisonInfo("test", MATCHING_RESOURCE), - new TestResourceComparisonInfo("test2", MATCHING_RESOURCE), + new TestResourceComparisonInfo("test", MATCHING_RESOURCES), + new TestResourceComparisonInfo("test2", MATCHING_RESOURCES), new TestResourceComparisonInfo("test3", GLOBAL)), Set.of(new TestResourceComparisonInfo("test3", GLOBAL), - new TestResourceComparisonInfo("test2", MATCHING_RESOURCE), - new TestResourceComparisonInfo("test", MATCHING_RESOURCE)))); + new TestResourceComparisonInfo("test2", MATCHING_RESOURCES), + new TestResourceComparisonInfo("test", MATCHING_RESOURCES)))); } @Test public void differentMultipleMatchingResource() { assertTrue(testResourcesRequireReload( Set.of( - new TestResourceComparisonInfo("test", MATCHING_RESOURCE), - new TestResourceComparisonInfo("test2", MATCHING_RESOURCE), + new TestResourceComparisonInfo("test", MATCHING_RESOURCES), + new TestResourceComparisonInfo("test2", MATCHING_RESOURCES), new TestResourceComparisonInfo("test3", GLOBAL)), Set.of(new TestResourceComparisonInfo("test3", GLOBAL), - new TestResourceComparisonInfo("test2", MATCHING_RESOURCE), - new TestResourceComparisonInfo("TEST", MATCHING_RESOURCE)))); + new TestResourceComparisonInfo("test2", MATCHING_RESOURCES), + new TestResourceComparisonInfo("TEST", MATCHING_RESOURCES)))); } } diff --git a/test-framework/junit5/src/test/java/io/quarkus/test/junit/util/QuarkusTestProfileAwareClassOrdererTest.java b/test-framework/junit5/src/test/java/io/quarkus/test/junit/util/QuarkusTestProfileAwareClassOrdererTest.java index 31d4edc559f50..acb5f2cf5b834 100644 --- a/test-framework/junit5/src/test/java/io/quarkus/test/junit/util/QuarkusTestProfileAwareClassOrdererTest.java +++ b/test-framework/junit5/src/test/java/io/quarkus/test/junit/util/QuarkusTestProfileAwareClassOrdererTest.java @@ -207,7 +207,7 @@ private void quarkusWithTestResourceMock(ClassDescriptor mock, WithTestResource withResourceMock = Mockito.mock(WithTestResource.class, withSettings().strictness(Strictness.LENIENT)); doReturn(managerClass).when(withResourceMock).value(); when(withResourceMock.scope()).thenReturn( - restrictToAnnotatedClass ? TestResourceScope.RESTRICTED_TO_CLASS : TestResourceScope.MATCHING_RESOURCE); + restrictToAnnotatedClass ? TestResourceScope.RESTRICTED_TO_CLASS : TestResourceScope.MATCHING_RESOURCES); when(mock.findRepeatableAnnotations(WithTestResource.class)).thenReturn(List.of(withResourceMock)); }