Configure index in @ParameterizedTest display names
This commit prepends "[{index}] " to all custom display names
configured via @ParameterizedTest.
This provides better diagnostics between the "technical names" reported
on the CI server vs. the "display names" reported within a developer's
IDE.
See gh-23451
			
			
This commit is contained in:
		
							parent
							
								
									b173a93e72
								
							
						
					
					
						commit
						c004ef888c
					
				|  | @ -857,7 +857,7 @@ class CronTriggerTests { | ||||||
| 
 | 
 | ||||||
| 	@Retention(RetentionPolicy.RUNTIME) | 	@Retention(RetentionPolicy.RUNTIME) | ||||||
| 	@Target(ElementType.METHOD) | 	@Target(ElementType.METHOD) | ||||||
| 	@ParameterizedTest(name = "localDateTime [{0}], time zone [{1}]") | 	@ParameterizedTest(name = "[{index}] localDateTime[{0}], time zone[{1}]") | ||||||
| 	@MethodSource("parameters") | 	@MethodSource("parameters") | ||||||
| 	@interface ParameterizedCronTriggerTest { | 	@interface ParameterizedCronTriggerTest { | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -143,7 +143,7 @@ public abstract class AbstractDataBufferAllocatingTests { | ||||||
| 
 | 
 | ||||||
| 	@Retention(RetentionPolicy.RUNTIME) | 	@Retention(RetentionPolicy.RUNTIME) | ||||||
| 	@Target(ElementType.METHOD) | 	@Target(ElementType.METHOD) | ||||||
| 	@ParameterizedTest(name = "{0}") | 	@ParameterizedTest(name = "[{index}] {0}") | ||||||
| 	@MethodSource("org.springframework.core.io.buffer.AbstractDataBufferAllocatingTests#dataBufferFactories()") | 	@MethodSource("org.springframework.core.io.buffer.AbstractDataBufferAllocatingTests#dataBufferFactories()") | ||||||
| 	public @interface ParameterizedDataBufferAllocatingTest { | 	public @interface ParameterizedDataBufferAllocatingTest { | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -51,7 +51,7 @@ class GenericXmlContextLoaderResourceLocationsTests { | ||||||
| 	private static final Log logger = LogFactory.getLog(GenericXmlContextLoaderResourceLocationsTests.class); | 	private static final Log logger = LogFactory.getLog(GenericXmlContextLoaderResourceLocationsTests.class); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 	@ParameterizedTest(name = "{0}") | 	@ParameterizedTest(name = "[{index}] {0}") | ||||||
| 	@MethodSource("contextConfigurationLocationsData") | 	@MethodSource("contextConfigurationLocationsData") | ||||||
| 	void assertContextConfigurationLocations(String testClassName, String[] expectedLocations) throws Exception { | 	void assertContextConfigurationLocations(String testClassName, String[] expectedLocations) throws Exception { | ||||||
| 		Class<?> testClass = ClassUtils.forName(getClass().getName() + "$" + testClassName, getClass().getClassLoader()); | 		Class<?> testClass = ClassUtils.forName(getClass().getName() + "$" + testClassName, getClass().getClassLoader()); | ||||||
|  |  | ||||||
|  | @ -118,7 +118,7 @@ public abstract class AbstractHttpHandlerIntegrationTests { | ||||||
| 
 | 
 | ||||||
| 	@Retention(RetentionPolicy.RUNTIME) | 	@Retention(RetentionPolicy.RUNTIME) | ||||||
| 	@Target(ElementType.METHOD) | 	@Target(ElementType.METHOD) | ||||||
| 	@ParameterizedTest(name = "{0}") | 	@ParameterizedTest(name = "[{index}] {0}") | ||||||
| 	@MethodSource("org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests#httpServers()") | 	@MethodSource("org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests#httpServers()") | ||||||
| 	// public for Kotlin | 	// public for Kotlin | ||||||
| 	public @interface ParameterizedHttpServerTest { | 	public @interface ParameterizedHttpServerTest { | ||||||
|  |  | ||||||
|  | @ -96,7 +96,7 @@ class HeadersAdaptersTests { | ||||||
| 
 | 
 | ||||||
| 	@Retention(RetentionPolicy.RUNTIME) | 	@Retention(RetentionPolicy.RUNTIME) | ||||||
| 	@Target(ElementType.METHOD) | 	@Target(ElementType.METHOD) | ||||||
| 	@ParameterizedTest(name = "{0}") | 	@ParameterizedTest(name = "[{index}] {0}") | ||||||
| 	@MethodSource("headers") | 	@MethodSource("headers") | ||||||
| 	@interface ParameterizedHeadersTest { | 	@interface ParameterizedHeadersTest { | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -57,15 +57,15 @@ class DefaultResponseErrorHandlerHttpStatusTests { | ||||||
| 	private final ClientHttpResponse response = mock(ClientHttpResponse.class); | 	private final ClientHttpResponse response = mock(ClientHttpResponse.class); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 	@ParameterizedTest(name = "error: [{0}], exception: [{1}]") | 	@ParameterizedTest(name = "[{index}] error: [{0}]") | ||||||
| 	@DisplayName("hasError() returns true") | 	@DisplayName("hasError() returns true") | ||||||
| 	@MethodSource("errorCodes") | 	@MethodSource("errorCodes") | ||||||
| 	void hasErrorTrue(HttpStatus httpStatus, Class<? extends Throwable> expectedExceptionClass) throws Exception { | 	void hasErrorTrue(HttpStatus httpStatus) throws Exception { | ||||||
| 		given(this.response.getRawStatusCode()).willReturn(httpStatus.value()); | 		given(this.response.getRawStatusCode()).willReturn(httpStatus.value()); | ||||||
| 		assertThat(this.handler.hasError(this.response)).isTrue(); | 		assertThat(this.handler.hasError(this.response)).isTrue(); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	@ParameterizedTest(name = "error: [{0}], exception: [{1}]") | 	@ParameterizedTest(name = "[{index}] error: [{0}], exception: [{1}]") | ||||||
| 	@DisplayName("handleError() throws an exception") | 	@DisplayName("handleError() throws an exception") | ||||||
| 	@MethodSource("errorCodes") | 	@MethodSource("errorCodes") | ||||||
| 	void handleErrorException(HttpStatus httpStatus, Class<? extends Throwable> expectedExceptionClass) throws Exception { | 	void handleErrorException(HttpStatus httpStatus, Class<? extends Throwable> expectedExceptionClass) throws Exception { | ||||||
|  | @ -75,8 +75,7 @@ class DefaultResponseErrorHandlerHttpStatusTests { | ||||||
| 		given(this.response.getRawStatusCode()).willReturn(httpStatus.value()); | 		given(this.response.getRawStatusCode()).willReturn(httpStatus.value()); | ||||||
| 		given(this.response.getHeaders()).willReturn(headers); | 		given(this.response.getHeaders()).willReturn(headers); | ||||||
| 
 | 
 | ||||||
| 		assertThatExceptionOfType(expectedExceptionClass).isThrownBy(() -> | 		assertThatExceptionOfType(expectedExceptionClass).isThrownBy(() -> this.handler.handleError(this.response)); | ||||||
| 				this.handler.handleError(this.response)); |  | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	static Object[][] errorCodes() { | 	static Object[][] errorCodes() { | ||||||
|  |  | ||||||
|  | @ -82,7 +82,7 @@ class RestTemplateIntegrationTests extends AbstractMockWebServerTests { | ||||||
| 
 | 
 | ||||||
| 	@Retention(RetentionPolicy.RUNTIME) | 	@Retention(RetentionPolicy.RUNTIME) | ||||||
| 	@Target(ElementType.METHOD) | 	@Target(ElementType.METHOD) | ||||||
| 	@ParameterizedTest(name = "{0}") | 	@ParameterizedTest(name = "[{index}] {0}") | ||||||
| 	@MethodSource("clientHttpRequestFactories") | 	@MethodSource("clientHttpRequestFactories") | ||||||
| 	@interface ParameterizedRestTemplateTest { | 	@interface ParameterizedRestTemplateTest { | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -348,7 +348,7 @@ class ServletWebRequestHttpMethodsTests { | ||||||
| 
 | 
 | ||||||
| 	@Retention(RetentionPolicy.RUNTIME) | 	@Retention(RetentionPolicy.RUNTIME) | ||||||
| 	@Target(ElementType.METHOD) | 	@Target(ElementType.METHOD) | ||||||
| 	@ParameterizedTest(name = "{0}") | 	@ParameterizedTest(name = "[{index}] {0}") | ||||||
| 	@ValueSource(strings = { "GET", "HEAD" }) | 	@ValueSource(strings = { "GET", "HEAD" }) | ||||||
| 	@interface ParameterizedHttpMethodTest { | 	@interface ParameterizedHttpMethodTest { | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -73,7 +73,7 @@ class WebClientIntegrationTests { | ||||||
| 
 | 
 | ||||||
| 	@Retention(RetentionPolicy.RUNTIME) | 	@Retention(RetentionPolicy.RUNTIME) | ||||||
| 	@Target(ElementType.METHOD) | 	@Target(ElementType.METHOD) | ||||||
| 	@ParameterizedTest(name = "webClient [{0}]") | 	@ParameterizedTest(name = "[{index}] webClient [{0}]") | ||||||
| 	@MethodSource("arguments") | 	@MethodSource("arguments") | ||||||
| 	@interface ParameterizedWebClientTest { | 	@interface ParameterizedWebClientTest { | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -65,7 +65,7 @@ class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests { | ||||||
| 
 | 
 | ||||||
| 	@Retention(RetentionPolicy.RUNTIME) | 	@Retention(RetentionPolicy.RUNTIME) | ||||||
| 	@Target(ElementType.METHOD) | 	@Target(ElementType.METHOD) | ||||||
| 	@ParameterizedTest(name = "server [{0}] webClient [{1}]") | 	@ParameterizedTest(name = "[{index}] server [{0}], webClient [{1}]") | ||||||
| 	@MethodSource("arguments") | 	@MethodSource("arguments") | ||||||
| 	protected @interface ParameterizedSseTest { | 	protected @interface ParameterizedSseTest { | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -80,7 +80,7 @@ abstract class AbstractWebSocketIntegrationTests { | ||||||
| 
 | 
 | ||||||
| 	@Retention(RetentionPolicy.RUNTIME) | 	@Retention(RetentionPolicy.RUNTIME) | ||||||
| 	@Target(ElementType.METHOD) | 	@Target(ElementType.METHOD) | ||||||
| 	@ParameterizedTest(name = "client[{0}] - server [{1}]") | 	@ParameterizedTest(name = "[{index}] client[{0}], server[{1}]") | ||||||
| 	@MethodSource("arguments") | 	@MethodSource("arguments") | ||||||
| 	@interface ParameterizedWebSocketTest { | 	@interface ParameterizedWebSocketTest { | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -116,7 +116,7 @@ class HandlerMethodAnnotationDetectionTests { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 	@ParameterizedTest(name = "controller [{0}], auto-proxy [{1}]") | 	@ParameterizedTest(name = "[{index}] controller [{0}], auto-proxy [{1}]") | ||||||
| 	@MethodSource("handlerTypes") | 	@MethodSource("handlerTypes") | ||||||
| 	void testRequestMappingMethod(Class<?> controllerType, boolean useAutoProxy) throws Exception { | 	void testRequestMappingMethod(Class<?> controllerType, boolean useAutoProxy) throws Exception { | ||||||
| 		setUp(controllerType, useAutoProxy); | 		setUp(controllerType, useAutoProxy); | ||||||
|  |  | ||||||
|  | @ -74,7 +74,7 @@ public abstract class AbstractWebSocketIntegrationTests { | ||||||
| 
 | 
 | ||||||
| 	@Retention(RetentionPolicy.RUNTIME) | 	@Retention(RetentionPolicy.RUNTIME) | ||||||
| 	@Target(ElementType.METHOD) | 	@Target(ElementType.METHOD) | ||||||
| 	@ParameterizedTest(name = "server [{0}], client [{1}]") | 	@ParameterizedTest(name = "[{index}] server [{0}], client [{1}]") | ||||||
| 	@MethodSource("argumentsFactory") | 	@MethodSource("argumentsFactory") | ||||||
| 	protected @interface ParameterizedWebSocketTest { | 	protected @interface ParameterizedWebSocketTest { | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue