iOS Unit testing for Couchbase Lite

69 views
Skip to first unread message

parvez....@decurtis.com

unread,
Jun 19, 2017, 9:40:50 AM6/19/17
to Couchbase Mobile
For an ios application (in Swift) backed by Couchbase lite (using CouchbaseLite.framework), we need to implement unit test for the various cases:
  1. Attachment downloading.
  2. For document deletion.
  3. KVO
How we can use CBLTestCase & CBLTestCaseWithDB in our unit tests? Will attachment downloading can be done via a real sync gateway? I did not find any article / tutorial that shows how CBL implementation can be unit tested in an iOS application.

Thanks

Jens Alfke

unread,
Jun 19, 2017, 8:29:06 PM6/19/17
to mobile-c...@googlegroups.com

On Jun 19, 2017, at 6:40 AM, parvez....@decurtis.com wrote:

How we can use CBLTestCase & CBLTestCaseWithDB in our unit tests?

Those are internal classes, not part of the API. They’re used for testing Couchbase Lite itself.

If you want to try to use them in your own code, they’re open source so go ahead. But they come with no instructions, no support, and no guarantee that they won’t disappear or change incompatibly at any time. (They also use internal APIs that I would discourage you from using for the same reasons.)

—Jens

parvez....@decurtis.com

unread,
Jun 20, 2017, 11:09:21 AM6/20/17
to Couchbase Mobile
Do I need to use actual syncing in our unit test for attachment downloading as the respective implementation is using deferred downloading of attachment. Here by actual syncing I mean to say we need to specify an actual sync gateway url to connect to and perform replication.

Jens Alfke

unread,
Jun 20, 2017, 3:14:07 PM6/20/17
to mobile-c...@googlegroups.com

On Jun 20, 2017, at 8:09 AM, parvez....@decurtis.com wrote:

Do I need to use actual syncing in our unit test for attachment downloading as the respective implementation is using deferred downloading of attachment. Here by actual syncing I mean to say we need to specify an actual sync gateway url to connect to and perform replication.

That’s one way of doing it. Another way is to use mocks.

(In the couchbase-lite-ios unit tests, we do use a real SG instance, running on localhost, with a set of canned Walrus databases that are checked into the repo. I know that according to the rules this isn’t true unit testing because it has external dependencies, but it’s worked pretty well for us. It does complicate automated testing, though.)

—Jens
Reply all
Reply to author
Forward
0 new messages