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:
Sam Brannen 2019-08-28 17:06:23 +02:00
parent b173a93e72
commit c004ef888c
13 changed files with 16 additions and 17 deletions

View File

@ -857,7 +857,7 @@ class CronTriggerTests {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@ParameterizedTest(name = "localDateTime [{0}], time zone [{1}]")
@ParameterizedTest(name = "[{index}] localDateTime[{0}], time zone[{1}]")
@MethodSource("parameters")
@interface ParameterizedCronTriggerTest {
}

View File

@ -143,7 +143,7 @@ public abstract class AbstractDataBufferAllocatingTests {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@ParameterizedTest(name = "{0}")
@ParameterizedTest(name = "[{index}] {0}")
@MethodSource("org.springframework.core.io.buffer.AbstractDataBufferAllocatingTests#dataBufferFactories()")
public @interface ParameterizedDataBufferAllocatingTest {
}

View File

@ -51,7 +51,7 @@ class GenericXmlContextLoaderResourceLocationsTests {
private static final Log logger = LogFactory.getLog(GenericXmlContextLoaderResourceLocationsTests.class);
@ParameterizedTest(name = "{0}")
@ParameterizedTest(name = "[{index}] {0}")
@MethodSource("contextConfigurationLocationsData")
void assertContextConfigurationLocations(String testClassName, String[] expectedLocations) throws Exception {
Class<?> testClass = ClassUtils.forName(getClass().getName() + "$" + testClassName, getClass().getClassLoader());

View File

@ -118,7 +118,7 @@ public abstract class AbstractHttpHandlerIntegrationTests {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@ParameterizedTest(name = "{0}")
@ParameterizedTest(name = "[{index}] {0}")
@MethodSource("org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests#httpServers()")
// public for Kotlin
public @interface ParameterizedHttpServerTest {

View File

@ -96,7 +96,7 @@ class HeadersAdaptersTests {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@ParameterizedTest(name = "{0}")
@ParameterizedTest(name = "[{index}] {0}")
@MethodSource("headers")
@interface ParameterizedHeadersTest {
}

View File

@ -57,15 +57,15 @@ class DefaultResponseErrorHandlerHttpStatusTests {
private final ClientHttpResponse response = mock(ClientHttpResponse.class);
@ParameterizedTest(name = "error: [{0}], exception: [{1}]")
@ParameterizedTest(name = "[{index}] error: [{0}]")
@DisplayName("hasError() returns true")
@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());
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")
@MethodSource("errorCodes")
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.getHeaders()).willReturn(headers);
assertThatExceptionOfType(expectedExceptionClass).isThrownBy(() ->
this.handler.handleError(this.response));
assertThatExceptionOfType(expectedExceptionClass).isThrownBy(() -> this.handler.handleError(this.response));
}
static Object[][] errorCodes() {

View File

@ -82,7 +82,7 @@ class RestTemplateIntegrationTests extends AbstractMockWebServerTests {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@ParameterizedTest(name = "{0}")
@ParameterizedTest(name = "[{index}] {0}")
@MethodSource("clientHttpRequestFactories")
@interface ParameterizedRestTemplateTest {
}

View File

@ -348,7 +348,7 @@ class ServletWebRequestHttpMethodsTests {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@ParameterizedTest(name = "{0}")
@ParameterizedTest(name = "[{index}] {0}")
@ValueSource(strings = { "GET", "HEAD" })
@interface ParameterizedHttpMethodTest {
}

View File

@ -73,7 +73,7 @@ class WebClientIntegrationTests {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@ParameterizedTest(name = "webClient [{0}]")
@ParameterizedTest(name = "[{index}] webClient [{0}]")
@MethodSource("arguments")
@interface ParameterizedWebClientTest {
}

View File

@ -65,7 +65,7 @@ class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@ParameterizedTest(name = "server [{0}] webClient [{1}]")
@ParameterizedTest(name = "[{index}] server [{0}], webClient [{1}]")
@MethodSource("arguments")
protected @interface ParameterizedSseTest {
}

View File

@ -80,7 +80,7 @@ abstract class AbstractWebSocketIntegrationTests {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@ParameterizedTest(name = "client[{0}] - server [{1}]")
@ParameterizedTest(name = "[{index}] client[{0}], server[{1}]")
@MethodSource("arguments")
@interface ParameterizedWebSocketTest {
}

View File

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

View File

@ -74,7 +74,7 @@ public abstract class AbstractWebSocketIntegrationTests {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@ParameterizedTest(name = "server [{0}], client [{1}]")
@ParameterizedTest(name = "[{index}] server [{0}], client [{1}]")
@MethodSource("argumentsFactory")
protected @interface ParameterizedWebSocketTest {
}