Scan converters with @WebMvcTest and @WebFluxTest

This commit makes sure to automatically scan `Converter` and
`GenericConverter` beans when a test uses `@WebMvcTest` or
`@WebFluxTest`.

Closes gh-10802
This commit is contained in:
Stephane Nicoll
2017-11-10 15:58:27 +01:00
parent c40517b0ce
commit 4e88db9883
13 changed files with 301 additions and 8 deletions

View File

@@ -5998,9 +5998,9 @@ A list of the auto-configuration that is enabled by `@JsonTest` can be
==== Auto-configured Spring MVC Tests
To test Spring MVC controllers are working as expected, you can use the `@WebMvcTest`
annotation. `@WebMvcTest` auto-configures the Spring MVC infrastructure and limits
scanned beans to `@Controller`, `@ControllerAdvice`, `@JsonComponent`, `Filter`,
`WebMvcConfigurer`, and `HandlerMethodArgumentResolver`. Regular `@Component` beans
are not scanned when using this annotation.
scanned beans to `@Controller`, `@ControllerAdvice`, `@JsonComponent`, `@Converter`,
`Filter`, `WebMvcConfigurer`, and `HandlerMethodArgumentResolver`. Regular `@Component`
beans are not scanned when using this annotation.
Often, `@WebMvcTest` is limited to a single controller and is used in combination with
`@MockBean` to provide mock implementations for required collaborators.
@@ -6102,8 +6102,8 @@ A list of the auto-configuration settings that are enabled by `@WebMvcTest` can
To test that Spring WebFlux controllers are working as expected, you can use the
`@WebFluxTest` annotation. `@WebFluxTest` auto-configures the Spring WebFlux
infrastructure and limits scanned beans to `@Controller`, `@ControllerAdvice`,
`@JsonComponent`, and `WebFluxConfigurer`. Regular `@Component` beans are not scanned
when the `@WebFluxTest` annotation is used.
`@JsonComponent`, `Converter`, and `WebFluxConfigurer`. Regular `@Component` beans are
not scanned when the `@WebFluxTest` annotation is used.
Often, `@WebFluxTest` is limited to a single controller and used in combination with the
`@MockBean` annotation to provide mock implementations for required collaborators.