Annotation Interface WithTestResource
As of Quarkus 3.16, the default behavior of the annotation (meaning that scope has not been set)
is that test classes annotated with the same WithTestResource will not force a restart
of Quarkus.
The equivalent behavior to QuarkusTestResource(restrictToAnnotatedClass = false) is to use
WithTestResource(scope = TestResourceScope.GLOBAL),
while the equivalent behavior to QuarkusTestResource(restrictToAnnotatedClass = true) is to use
WithTestResource(scope = TestResourceScope.RESTRICTED_TO_CLASS),
WARNING: this annotation, introduced in 3.13, caused some issues so it was decided to undeprecate
QuarkusTestResource and rework the behavior of this annotation. For now, we recommend not using it
until we improve its behavior.
Note: When using the scope=TestResourceScope.RESTRICTED_TO_CLASS, each test that is annotated
with @WithTestResource will result in the application being re-augmented and restarted (in a similar fashion
as happens in dev-mode when a change is detected) in order to incorporate the settings configured by the annotation.
If there are many instances of the annotation used throughout the testsuite, this could result in slow test execution.
All WithTestResource annotations in the test module
are discovered (regardless of the test which contains the annotation)
and their corresponding QuarkusTestResourceLifecycleManager
started before any test is run.
Note that test resources are never restarted when running @Nested test classes.
-
Nested Class Summary
Nested Classes -
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanWhether this test resource is to be started in parallel (concurrently) along with others also marked as parallelDefines how Quarkus behaves with regard to the application of the resource to this test and the test-suite in general.
-
Element Details
-
value
Class<? extends QuarkusTestResourceLifecycleManager> value- Returns:
- The class managing the lifecycle of the test resource.
-
-
-
initArgs
ResourceArg[] initArgs- Returns:
- The arguments to be passed to the
QuarkusTestResourceLifecycleManager - See Also:
- Default:
- {}
-
parallel
boolean parallelWhether this test resource is to be started in parallel (concurrently) along with others also marked as parallel- Default:
- false
-
scope
TestResourceScope scopeDefines how Quarkus behaves with regard to the application of the resource to this test and the test-suite in general. The default isTestResourceScope.MATCHING_RESOURCESwhich means that if two tests are annotated with the sameWithTestResourceannotation, no restart will take place between tests.- Default:
- MATCHING_RESOURCES
-