@@ -31,9 +31,19 @@ private TestResourceUtil() {
31
31
* This is where we decide if the test resources of the current state vs the ones required by the next test class
32
32
* to be executed require a Quarkus restart.
33
33
*/
34
- static boolean testResourcesRequireReload (QuarkusTestExtensionState state , Class <?> nextTestClass ) {
34
+ static boolean testResourcesRequireReload (QuarkusTestExtensionState state , Class <?> nextTestClass ,
35
+ Class <? extends QuarkusTestProfile > nextTestClassProfile ) {
36
+ QuarkusTestProfile profileInstance = null ;
37
+ if (nextTestClassProfile != null ) {
38
+ try {
39
+ profileInstance = nextTestClassProfile .getConstructor ().newInstance ();
40
+ } catch (Exception e ) {
41
+ throw new RuntimeException (e );
42
+ }
43
+ }
35
44
Set <TestResourceManager .TestResourceComparisonInfo > existingTestResources = existingTestResources (state );
36
- Set <TestResourceManager .TestResourceComparisonInfo > nextTestResources = nextTestResources (nextTestClass );
45
+ Set <TestResourceManager .TestResourceComparisonInfo > nextTestResources = nextTestResources (nextTestClass ,
46
+ profileInstance );
37
47
38
48
return TestResourceManager .testResourcesRequireReload (existingTestResources , nextTestResources );
39
49
}
@@ -54,9 +64,20 @@ static Set<TestResourceManager.TestResourceComparisonInfo> existingTestResources
54
64
return Collections .emptySet ();
55
65
}
56
66
57
- static Set <TestResourceManager .TestResourceComparisonInfo > nextTestResources (Class <?> requiredTestClass ) {
67
+ static Set <TestResourceManager .TestResourceComparisonInfo > nextTestResources (Class <?> requiredTestClass ,
68
+ QuarkusTestProfile profileInstance ) {
69
+
70
+ List <TestResourceManager .TestResourceClassEntry > entriesFromProfile = Collections .emptyList ();
71
+ if (profileInstance != null ) {
72
+ entriesFromProfile = new ArrayList <>(profileInstance .testResources ().size ());
73
+ for (QuarkusTestProfile .TestResourceEntry entry : profileInstance .testResources ()) {
74
+ entriesFromProfile .add (new TestResourceManager .TestResourceClassEntry (entry .getClazz (), entry .getArgs (), null ,
75
+ entry .isParallel (), TestResourceScope .MATCHING_RESOURCES ));
76
+ }
77
+ }
78
+
58
79
return TestResourceManager
59
- .testResourceComparisonInfo (requiredTestClass , getTestClassesLocation (requiredTestClass ));
80
+ .testResourceComparisonInfo (requiredTestClass , getTestClassesLocation (requiredTestClass ), entriesFromProfile );
60
81
}
61
82
62
83
/**
@@ -92,7 +113,7 @@ static <T> List<T> copyEntriesFromProfile(
92
113
T instance = (T ) testResourceClassEntryConstructor .newInstance (
93
114
Class .forName (testResource .getClazz ().getName (), true , classLoader ), testResource .getArgs (),
94
115
null , testResource .isParallel (),
95
- Enum .valueOf (testResourceScopeClass , TestResourceScope .RESTRICTED_TO_CLASS .name ()));
116
+ Enum .valueOf (testResourceScopeClass , TestResourceScope .MATCHING_RESOURCES .name ()));
96
117
result .add (instance );
97
118
}
98
119
0 commit comments