|
17 | 17 | package org.springframework.test.context.aot;
|
18 | 18 |
|
19 | 19 | import java.util.Arrays;
|
| 20 | +import java.util.HashSet; |
20 | 21 | import java.util.LinkedHashSet;
|
21 | 22 | import java.util.List;
|
22 | 23 | import java.util.Map;
|
@@ -178,18 +179,27 @@ public void processAheadOfTime(Stream<Class<?>> testClasses) throws TestContextA
|
178 | 179 |
|
179 | 180 | MultiValueMap<MergedContextConfiguration, Class<?>> mergedConfigMappings = new LinkedMultiValueMap<>();
|
180 | 181 | ClassLoader classLoader = getClass().getClassLoader();
|
| 182 | + Set<String> visitedTestClassNames = new HashSet<>(); |
181 | 183 | testClasses.forEach(testClass -> {
|
182 |
| - MergedContextConfiguration mergedConfig = buildMergedContextConfiguration(testClass); |
183 |
| - mergedConfigMappings.add(mergedConfig, testClass); |
184 |
| - collectRuntimeHintsRegistrarClasses(testClass, coreRuntimeHintsRegistrarClasses); |
185 |
| - reflectiveRuntimeHintsRegistrar.registerRuntimeHints(this.runtimeHints, testClass); |
186 |
| - this.testRuntimeHintsRegistrars.forEach(registrar -> { |
187 |
| - if (logger.isTraceEnabled()) { |
188 |
| - logger.trace("Processing RuntimeHints contribution from class [%s]" |
189 |
| - .formatted(registrar.getClass().getCanonicalName())); |
| 184 | + String testClassName = testClass.getName(); |
| 185 | + if (visitedTestClassNames.add(testClassName)) { |
| 186 | + MergedContextConfiguration mergedConfig = buildMergedContextConfiguration(testClass); |
| 187 | + mergedConfigMappings.add(mergedConfig, testClass); |
| 188 | + collectRuntimeHintsRegistrarClasses(testClass, coreRuntimeHintsRegistrarClasses); |
| 189 | + reflectiveRuntimeHintsRegistrar.registerRuntimeHints(this.runtimeHints, testClass); |
| 190 | + this.testRuntimeHintsRegistrars.forEach(registrar -> { |
| 191 | + if (logger.isTraceEnabled()) { |
| 192 | + logger.trace("Processing RuntimeHints contribution from class [%s]" |
| 193 | + .formatted(registrar.getClass().getCanonicalName())); |
| 194 | + } |
| 195 | + registrar.registerHints(this.runtimeHints, testClass, classLoader); |
| 196 | + }); |
| 197 | + } |
| 198 | + else { |
| 199 | + if (logger.isDebugEnabled()) { |
| 200 | + logger.debug("Skipping duplicate test class: " + testClassName); |
190 | 201 | }
|
191 |
| - registrar.registerHints(this.runtimeHints, testClass, classLoader); |
192 |
| - }); |
| 202 | + } |
193 | 203 | });
|
194 | 204 |
|
195 | 205 | coreRuntimeHintsRegistrarClasses.stream()
|
|
0 commit comments