incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Klo <>
Subject Command Line Design Doc Testing
Date Mon, 19 Mar 2012 18:48:26 GMT
Paul Davis suggested I ping the dev list to let you know of a process/framework I've cobbled
together for unit testing design documents, and just to aid in flat out debugging when using
the CouchApp python script..

Essentially I've pulled together some pieces of CouchDB's main.js,  jsUnity (,
some Mock Objects  and convenience functionality that I've rolled myself, Spidermonkey, and
an extra command for CouchApp.  My motivation? Sick of the roundtripping from editor, to couch,
to curl, to indexing, to log files, and back with no real way to use a debugger with breakpoints.
 I considered using Node.js however I needed E4X support - so that meant Spidermonkey or Rhino.
(BTW if anyone knows of a schema aware XML parser that works in Spidermonkey that's better
than E4X, I'm all ears). Since Spidermonkey is already used by CouchDB - seemed like the logical
choice, but I'm sure this could probably work with Rhino too.  I also wanted to be able to
eventually get this working within our CI environment which uses Jenkins - so command line
use was pretty important.

So our general environment - we use CouchApp to deploy design docs (and using !code and !json
macros), as well as have a python business layer.  I leveraged the codebase already there
for converting a file system into a design doc then  load it into spidermonkey and run a testsuite
against it.  This ended up making it very easy to add breakpoints and such in your scripts
as well as quickly regression test a change you might make in some shared library.

It's still pretty raw - but it currently works for our needs;
is the common test code
is just the current version of jsUnity
are some test cases using this framework
another set of test cases, that use maps containing E4X.

And then for running the tests with CouchApp:
 is the extension command  to configure it to work you'll need to add the following to your

At some point, I'll probably pull all the pieces out into their own project to make it easier
for others to incorporate.

I still need a better mock interface for the request object passed into list/show/filters.
That probably won't happen until I get a better idea of what I need to use from that perspective.

Any questions, comments, criticism please feel free to shoot them my way... 


- Jim

Jim Klo
Senior Software Engineer
Center for Software Engineering
SRI International

View raw message