Reusable Containers (Experimental)

Couchbase Module

qianmoQqianmoQ· 更新于 2026-10-13· 阅读 3 分钟· 0 次阅读

登录后可跨设备保存划线和私人笔记登录

Couchbase Module

Testcontainers module for Couchbase. Couchbase is a document oriented NoSQL database.

Usage example

Running Couchbase as a stand-in in a test:

  1. Define a bucket:

    Bucket Definition

    BucketDefinition bucketDefinition = new BucketDefinition("mybucket");
  2. define a container:

    Container definition

    CouchbaseContainer container = new CouchbaseContainer(couchbaseImage).withBucket(bucketDefinition)
  3. create an cluster:

    Cluster creation

    Cluster cluster = Cluster.connect(
        container.getConnectionString(),
        container.getUsername(),
        container.getPassword()
    );

Adding this module to your project dependencies

Add the following dependency to your pom.xml/build.gradle file:

GradleMaven

testImplementation "org.testcontainers:testcontainers-couchbase:2.0.5"
<dependency>
    <groupId>org.testcontainers</groupId>
    <artifactId>testcontainers-couchbase</artifactId>
    <version>2.0.5</version>
    <scope>test</scope>
</dependency>

评论

登录后参与评论

正在加载评论…