@TargetSE(valueSE=TYPESE) @RetentionSE(valueSE=RUNTIMESE) @DocumentedSE @InheritedSE @BootstrapWith(value=org.springframework.boot.test.autoconfigure.web.client.RestClientTestContextBootstrapper.class) @ExtendWith(value=org.springframework.test.context.junit.jupiter.SpringExtension.class) @OverrideAutoConfiguration(enabled=false) @TypeExcludeFilters(value=org.springframework.boot.test.autoconfigure.web.client.RestClientExcludeFilter.class) @AutoConfigureCache @AutoConfigureWebClient @AutoConfigureMockRestServiceServer @ImportAutoConfiguration public @interface RestClientTest
@RunWith(SpringRunner.class) と組み合わせて使用できるアノテーション。テストが RestTemplateBuilder を使用する Bean のみに焦点を当てている場合に使用できます。 このアノテーションを使用すると、完全な自動構成が無効になり、代わりに残りのクライアントテストに関連する構成のみが適用されます(つまり、Jackson または GSON 自動構成と @JsonComponent Bean であり、通常の @Component Bean ではありません)。
デフォルトでは、RestClientTest でアノテーションが付けられたテストも MockRestServiceServer を自動構成します。よりきめ細かい制御には、@AutoConfigureMockRestServiceServer アノテーションを使用できます。
RestTemplateBuilder を使用せず、代わりに RestTemplate を直接注入する Bean をテストする場合は、@AutoConfigureWebClient(registerRestTemplate=true) を追加できます。
| 修飾子と型 | オプションの要素と説明 |
|---|---|
ClassSE<?>[] | components テストするコンポーネントを指定します。 |
ClassSE<?>[] | excludeAutoConfiguration このテストに適用する必要がある自動構成の除外。 |
org.springframework.context.annotation.ComponentScan.Filter[] | excludeFilters それ以外の場合はアプリケーションコンテキストに追加される Bean のフィルタリングに使用できる除外フィルターのセット。 |
org.springframework.context.annotation.ComponentScan.Filter[] | includeFilters 他の方法でフィルタリングされた Bean をアプリケーションコンテキストに追加するために使用できる一連の組み込みフィルター。 |
StringSE[] | properties テストを実行する前に Spring Environment に追加する必要がある key = value 形式のプロパティ。 |
boolean | useDefaultFilters@SpringBootApplication でデフォルトのフィルタリングを使用するかどうかを決定します。 |
ClassSE<?>[] | value テストするコンポーネントを指定します。 |
public abstract StringSE[] properties
Environment に追加する必要がある key = value 形式のプロパティ。@AliasFor(value="components") public abstract ClassSE<?>[] value
components() のエイリアスであり、他の属性が定義されていない場合に簡潔にするために使用できます。詳細については、components() を参照してください。components()public abstract boolean useDefaultFilters
@SpringBootApplication で使用するかどうかを決定します。デフォルトでは、@JsonComponent および Module Bean のみが含まれています。includeFilters(), excludeFilters()public abstract org.springframework.context.annotation.ComponentScan.Filter[] includeFilters
public abstract org.springframework.context.annotation.ComponentScan.Filter[] excludeFilters
@AliasFor(annotation=ImportAutoConfiguration.class, attribute="exclude") public abstract ClassSE<?>[] excludeAutoConfiguration
Copyright © 2019 Pivotal Software, Inc.. All rights reserved.