In memory INamedBucketProvider for integration testing in .NET

Writing integration tests for ASP.NET Core backends that use Entity Framework Core is easy because the InMemory database provider is offered. However, our backend uses Couchbase so I would need to hook up integration tests to an actual DB which is too much overhead. Is there an InMemory version of INamedBucketProvider/IBucket or could this be created in order to allow simpler integration testing with .NET Core and ASP.NET Core?

To my knowledge, there’s not currently an in-memory version of Couchbase for integration tests. I’ve played around with making one a few times, but got bogged down in the sheer complexity of the IBucket interface and all of its overloads. I usually just use Moq to fake the particular methods on IBucket that I need, but that’s easier for unit tests than integration tests.

To this end, there are some changes in the forthcoming 3.0 version of the SDK that have been made that will make an in-memory IBucket implementation much easier. Specifically, most of the overloads have been moved to extension methods so that there are far fewer methods to implement.

Another option, which we commonly use, is a Docker container copy of Couchbase that we run to support our tests. It adds 15-30 seconds of bootstrap time, but overall works well for us in our functional API testing. We also use it to support local machine development. We use this repo, which includes support for creating buckets, creating indexes, and fake data during startup. https://cloud.docker.com/u/btburnett3/repository/docker/btburnett3/couchbasefakeit

Brant

2 Likes