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 
(http://jsunity.com), 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;
https://github.com/jimklo/LearningRegistry/blob/data-services-proto/data_services/lib/test-common.js
 is the common test code
https://github.com/jimklo/LearningRegistry/blob/data-services-proto/data_services/lib/jsunity-0.6.js
 is just the current version of jsUnity
https://github.com/jimklo/LearningRegistry/blob/data-services-proto/data_services/standards-alignment-lr-paradata/tests/test-alignment.js
 are some test cases using this framework
https://github.com/jimklo/LearningRegistry/blob/data-services-proto/data_services/standards-alignment-dct-conformsTo/tests/test-alignment.js
 another set of test cases, that use maps containing E4X.

And then for running the tests with CouchApp:
https://github.com/jimklo/LearningRegistry/blob/data-services-proto/LR/lr/couchapp/exec_tests.py
  is the extension command  to configure it to work you'll need to add the 
following to your .couchapprc 
https://github.com/jimklo/LearningRegistry/blob/data-services-proto/data_services/standards-alignment-lr-paradata/.couchapprc

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... 

Thanks,

- Jim

Jim Klo
Senior Software Engineer
Center for Software Engineering
SRI International

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to