How can I test my couchbase client?

Hi everyone,

I want to test my java code that uses the couchbase java client, but without test it on a real cluster.
I wondered if there’s any in-memory cluster I can check it with (some kind of mock to the cluster), in order to run my unit tests.

I couldn’t find any couchbase server mock.

Please help!


Hi @Taykey,

actually there is nothing officially supported. What you can do and what I’d recommend is probably you want to mock the Bucket interface with Mockito or something and return the values that you’re expecting - if you want to unit test the interface.

If you want to really test it against something comparable, the closest is probably this: … you can build a jar and deploy it with your application.

@mnunberg has done some work recently and there might be a “1.0” version soon, according to some commits in there.

Hi @daschl,

I tried to use the project you wrote here, the problem is, that my code (DAO) actually suppose to talk to existing cluster and perform some operations about it, like get buckets and insert documents and I’m searching for “in memory server” or “cluster from code”, a real way to mock the couchbase cluster instead of really create a real one.

Do you have any other idea for me?


Well, If you just want to mock it, I recommend you to use something like Mockito and then mock out the Bucket interface.

I’ll look into it.