Auto-configured Data Couchbase Tests
You can use @DataCouchbaseTest
to test Couchbase applications.
By default, it configures a CouchbaseTemplate
or ReactiveCouchbaseTemplate
, scans for @Document
classes, and configures Spring Data Couchbase repositories.
Regular @Component
and @ConfigurationProperties
beans are not scanned when the @DataCouchbaseTest
annotation is used.
@EnableConfigurationProperties
can be used to include @ConfigurationProperties
beans.
(For more about using Couchbase with Spring Boot, see "Couchbase", earlier in this chapter.)
A list of the auto-configuration settings that are enabled by @DataCouchbaseTest can be found in the appendix.
|
The following example shows a typical setup for using Couchbase tests in Spring Boot:
-
Java
-
Kotlin
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.data.couchbase.DataCouchbaseTest;
@DataCouchbaseTest
class MyDataCouchbaseTests {
@Autowired
private SomeRepository repository;
// ...
}
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.data.couchbase.DataCouchbaseTest
@DataCouchbaseTest
class MyDataCouchbaseTests(@Autowired val repository: SomeRepository) {
// ...
}