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

@@ -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 {
}