Skip to content

Commit c004ef8

Browse files
committed
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 spring-projectsgh-23451
1 parent b173a93 commit c004ef8

File tree

13 files changed

+16
-17
lines changed

13 files changed

+16
-17
lines changed

spring-context/src/test/java/org/springframework/scheduling/support/CronTriggerTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ private static TriggerContext getTriggerContext(Date lastCompletionTime) {
857857

858858
@Retention(RetentionPolicy.RUNTIME)
859859
@Target(ElementType.METHOD)
860-
@ParameterizedTest(name = "localDateTime [{0}], time zone [{1}]")
860+
@ParameterizedTest(name = "[{index}] localDateTime[{0}], time zone[{1}]")
861861
@MethodSource("parameters")
862862
@interface ParameterizedCronTriggerTest {
863863
}

spring-core/src/test/java/org/springframework/core/io/buffer/AbstractDataBufferAllocatingTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ private static long getAllocations(List<PoolArenaMetric> metrics) {
143143

144144
@Retention(RetentionPolicy.RUNTIME)
145145
@Target(ElementType.METHOD)
146-
@ParameterizedTest(name = "{0}")
146+
@ParameterizedTest(name = "[{index}] {0}")
147147
@MethodSource("org.springframework.core.io.buffer.AbstractDataBufferAllocatingTests#dataBufferFactories()")
148148
public @interface ParameterizedDataBufferAllocatingTest {
149149
}

spring-test/src/test/java/org/springframework/test/context/support/GenericXmlContextLoaderResourceLocationsTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class GenericXmlContextLoaderResourceLocationsTests {
5151
private static final Log logger = LogFactory.getLog(GenericXmlContextLoaderResourceLocationsTests.class);
5252

5353

54-
@ParameterizedTest(name = "{0}")
54+
@ParameterizedTest(name = "[{index}] {0}")
5555
@MethodSource("contextConfigurationLocationsData")
5656
void assertContextConfigurationLocations(String testClassName, String[] expectedLocations) throws Exception {
5757
Class<?> testClass = ClassUtils.forName(getClass().getName() + "$" + testClassName, getClass().getClassLoader());

spring-web/src/test/java/org/springframework/http/server/reactive/AbstractHttpHandlerIntegrationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public static Flux<Long> testInterval(Duration period, int count) {
118118

119119
@Retention(RetentionPolicy.RUNTIME)
120120
@Target(ElementType.METHOD)
121-
@ParameterizedTest(name = "{0}")
121+
@ParameterizedTest(name = "[{index}] {0}")
122122
@MethodSource("org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests#httpServers()")
123123
// public for Kotlin
124124
public @interface ParameterizedHttpServerTest {

spring-web/src/test/java/org/springframework/http/server/reactive/HeadersAdaptersTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void putShouldOverrideExisting(String displayName, MultiValueMap<String, String>
9696

9797
@Retention(RetentionPolicy.RUNTIME)
9898
@Target(ElementType.METHOD)
99-
@ParameterizedTest(name = "{0}")
99+
@ParameterizedTest(name = "[{index}] {0}")
100100
@MethodSource("headers")
101101
@interface ParameterizedHeadersTest {
102102
}

spring-web/src/test/java/org/springframework/web/client/DefaultResponseErrorHandlerHttpStatusTests.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ class DefaultResponseErrorHandlerHttpStatusTests {
5757
private final ClientHttpResponse response = mock(ClientHttpResponse.class);
5858

5959

60-
@ParameterizedTest(name = "error: [{0}], exception: [{1}]")
60+
@ParameterizedTest(name = "[{index}] error: [{0}]")
6161
@DisplayName("hasError() returns true")
6262
@MethodSource("errorCodes")
63-
void hasErrorTrue(HttpStatus httpStatus, Class<? extends Throwable> expectedExceptionClass) throws Exception {
63+
void hasErrorTrue(HttpStatus httpStatus) throws Exception {
6464
given(this.response.getRawStatusCode()).willReturn(httpStatus.value());
6565
assertThat(this.handler.hasError(this.response)).isTrue();
6666
}
6767

68-
@ParameterizedTest(name = "error: [{0}], exception: [{1}]")
68+
@ParameterizedTest(name = "[{index}] error: [{0}], exception: [{1}]")
6969
@DisplayName("handleError() throws an exception")
7070
@MethodSource("errorCodes")
7171
void handleErrorException(HttpStatus httpStatus, Class<? extends Throwable> expectedExceptionClass) throws Exception {
@@ -75,8 +75,7 @@ void handleErrorException(HttpStatus httpStatus, Class<? extends Throwable> expe
7575
given(this.response.getRawStatusCode()).willReturn(httpStatus.value());
7676
given(this.response.getHeaders()).willReturn(headers);
7777

78-
assertThatExceptionOfType(expectedExceptionClass).isThrownBy(() ->
79-
this.handler.handleError(this.response));
78+
assertThatExceptionOfType(expectedExceptionClass).isThrownBy(() -> this.handler.handleError(this.response));
8079
}
8180

8281
static Object[][] errorCodes() {

spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class RestTemplateIntegrationTests extends AbstractMockWebServerTests {
8282

8383
@Retention(RetentionPolicy.RUNTIME)
8484
@Target(ElementType.METHOD)
85-
@ParameterizedTest(name = "{0}")
85+
@ParameterizedTest(name = "[{index}] {0}")
8686
@MethodSource("clientHttpRequestFactories")
8787
@interface ParameterizedRestTemplateTest {
8888
}

spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestHttpMethodsTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ private void setUpRequest(String method) {
348348

349349
@Retention(RetentionPolicy.RUNTIME)
350350
@Target(ElementType.METHOD)
351-
@ParameterizedTest(name = "{0}")
351+
@ParameterizedTest(name = "[{index}] {0}")
352352
@ValueSource(strings = { "GET", "HEAD" })
353353
@interface ParameterizedHttpMethodTest {
354354
}

spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class WebClientIntegrationTests {
7373

7474
@Retention(RetentionPolicy.RUNTIME)
7575
@Target(ElementType.METHOD)
76-
@ParameterizedTest(name = "webClient [{0}]")
76+
@ParameterizedTest(name = "[{index}] webClient [{0}]")
7777
@MethodSource("arguments")
7878
@interface ParameterizedWebClientTest {
7979
}

spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
6565

6666
@Retention(RetentionPolicy.RUNTIME)
6767
@Target(ElementType.METHOD)
68-
@ParameterizedTest(name = "server [{0}] webClient [{1}]")
68+
@ParameterizedTest(name = "[{index}] server [{0}], webClient [{1}]")
6969
@MethodSource("arguments")
7070
protected @interface ParameterizedSseTest {
7171
}

spring-webflux/src/test/java/org/springframework/web/reactive/socket/AbstractWebSocketIntegrationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ abstract class AbstractWebSocketIntegrationTests {
8080

8181
@Retention(RetentionPolicy.RUNTIME)
8282
@Target(ElementType.METHOD)
83-
@ParameterizedTest(name = "client[{0}] - server [{1}]")
83+
@ParameterizedTest(name = "[{index}] client[{0}], server[{1}]")
8484
@MethodSource("arguments")
8585
@interface ParameterizedWebSocketTest {
8686
}

spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HandlerMethodAnnotationDetectionTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ private void setUp(Class<?> controllerType, boolean useAutoProxy) {
116116
}
117117

118118

119-
@ParameterizedTest(name = "controller [{0}], auto-proxy [{1}]")
119+
@ParameterizedTest(name = "[{index}] controller [{0}], auto-proxy [{1}]")
120120
@MethodSource("handlerTypes")
121121
void testRequestMappingMethod(Class<?> controllerType, boolean useAutoProxy) throws Exception {
122122
setUp(controllerType, useAutoProxy);

spring-websocket/src/test/java/org/springframework/web/socket/AbstractWebSocketIntegrationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static Stream<Arguments> argumentsFactory() {
7474

7575
@Retention(RetentionPolicy.RUNTIME)
7676
@Target(ElementType.METHOD)
77-
@ParameterizedTest(name = "server [{0}], client [{1}]")
77+
@ParameterizedTest(name = "[{index}] server [{0}], client [{1}]")
7878
@MethodSource("argumentsFactory")
7979
protected @interface ParameterizedWebSocketTest {
8080
}

0 commit comments

Comments
 (0)