@TargetSE(valueSE=TYPESE) @RetentionSE(valueSE=RUNTIMESE) @DocumentedSE @InheritedSE @BootstrapWith(value=org.springframework.boot.test.autoconfigure.jdbc.JdbcTestContextBootstrapper.class) @ExtendWith(value=org.springframework.test.context.junit.jupiter.SpringExtension.class) @OverrideAutoConfiguration(enabled=false) @TypeExcludeFilters(value=JdbcTypeExcludeFilter.class) @Transactional @AutoConfigureCache @AutoConfigureJdbc @AutoConfigureTestDatabase @ImportAutoConfiguration public @interface JdbcTest
このアノテーションを使用すると、完全な自動構成が無効になり、代わりに JDBC テストに関連する構成のみが適用されます。
デフォルトでは、@JdbcTest
アノテーションが付けられたテストはトランザクションであり、各テストの終わりにロールバックします。また、組み込みのインメモリデータベースを使用します(明示的または通常自動構成された DataSource を置き換えます)。@AutoConfigureTestDatabase
アノテーションを使用して、これらの設定をオーバーライドできます。
完全なアプリケーション構成をロードしたいが、埋め込みデータベースを使用する場合は、このアノテーションではなく、@SpringBootTest
と @AutoConfigureTestDatabase
の組み合わせを検討する必要があります。
JUnit 4 を使用する場合、このアノテーションは @RunWith(SpringRunner.class)
と組み合わせて使用する必要があります。
AutoConfigureJdbc
, AutoConfigureTestDatabase
, AutoConfigureCache
修飾子と型 | オプションの要素と説明 |
---|---|
ClassSE<?>[] | excludeAutoConfiguration このテストに適用する必要がある自動構成の除外。 |
ComponentScan.Filter[] | excludeFilters それ以外の場合はアプリケーションコンテキストに追加される Bean のフィルタリングに使用できる除外フィルターのセット。 |
ComponentScan.Filter[] | includeFilters 他の方法でフィルタリングされた Bean をアプリケーションコンテキストに追加するために使用できる一連の組み込みフィルター。 |
StringSE[] | properties テストの実行前に Spring Environment に追加する必要がある key = value 形式のプロパティ。 |
boolean | useDefaultFilters @SpringBootApplication でデフォルトのフィルタリングを使用するかどうかを決定します。 |
public abstract StringSE[] properties
Environment
に追加する必要がある key = value 形式のプロパティ。public abstract boolean useDefaultFilters
@SpringBootApplication
でデフォルトのフィルタリングを使用するかどうかを決定します。デフォルトでは、Bean は含まれません。includeFilters()
, excludeFilters()
public abstract ComponentScan.Filter[] includeFilters
public abstract ComponentScan.Filter[] excludeFilters
@AliasFor(annotation=ImportAutoConfiguration.class, attribute="exclude") public abstract ClassSE<?>[] excludeAutoConfiguration