Skip to content

TestResourceScope.MATCHING_RESOURCES ignores configuration annotations from QuarkusTestResourceConfigurableLifecycleManager #44129

@yrodiere

Description

@yrodiere

Describe the bug

From what I can see, only the FQCN of the test resource lifecycle manager and the configured scope are taken into account when grouping together tests with matching resources:

public static Set<TestResourceManager.TestResourceComparisonInfo> testResourceComparisonInfo(Class<?> testClass,
Path testClassLocation) {
Set<TestResourceClassEntry> uniqueEntries = getUniqueTestResourceClassEntries(testClass, testClassLocation, null);
if (uniqueEntries.isEmpty()) {
return Collections.emptySet();
}
Set<TestResourceManager.TestResourceComparisonInfo> result = new HashSet<>(uniqueEntries.size());
for (TestResourceClassEntry entry : uniqueEntries) {
result.add(new TestResourceComparisonInfo(entry.testResourceLifecycleManagerClass().getName(), entry.getScope()));
}
return result;
}

This seems incomplete, as test resource lifecycle managers can implement QuarkusTestResourceConfigurableLifecycleManager to be customized per-test, like this:

https://github.com/quarkusio/search.quarkus.io/blob/41e3b9f2de465ea2dc74efaa46ee44b310d5cc08/src/test/java/io/quarkus/search/app/testsupport/QuarkusIOSample.java#L510-L531

https://github.com/yrodiere/search.quarkus.io/blob/42ebd004b6fa5d92960b0615fb8ead6b1b6cb726/src/test/java/io/quarkus/search/app/SearchServiceTest.java#L42

Expected behavior

Tests are considered to have matching resources if they have the same resource lifecycle managers with the same arguments.

Actual behavior

Tests are considered to have matching resources if they have the same resource lifecycle managers, regardless of arguments.

How to Reproduce?

Check out quarkusio/search.quarkus.io#345 , revert the last commit, and see how resources are reused despite the

Or, probably simpler, add a unit test next to the existing ones for @WithTestResource within Quarkus itself.

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

Related conversation: quarkusio/search.quarkus.io#345

PR introducing the feature: #42852

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions