couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lena Herrmann <l...@zeromail.org>
Subject HTTP API testsuite finished - rundown and left TODOs
Date Sat, 03 Apr 2010 13:20:06 GMT
Hi!

I've finished the testsuite for couch.js and jquery.couch.js. Comments 
still welcome.

http://github.com/lenalena/couchdb/tree/testsuite


I fixed a couple of things as I went along. Other things I haven't fixed 
yet, but created tickets, see below.

The major thing that has to be done now is the integration into Futon. 
As all the tests together (more than 500 assertions and even more 
database hits) need some time to run (around 250ms usually, YMMV). So 
it's maybe the best to provide the possibility to run the different 
files with the specs (I've split them into eight files, this can be 
changed easily) separately.

The most simple way to do this is to dublicate the run.html file, make 
each copy run one spec file, link them into Futon, and integrate the 
result somehow into Futon's CSS. Any takers?


Running it
~~~~~~~~~~

http://github.com/lenalena/couchdb/tree/testsuite

If you want to run the testsuite, clone the project, compile and run in 
dev mode, and browse to this site: 
http://127.0.0.1:5984/_utils/spec/run.html

It works in at least Firefox >= 3.6 and Safari >= 4.0.4.


What is where
~~~~~~~~~~~~~

  * The two files I've tested:
/share/www/script/couch.js
/share/www/script/jquery.couch.js

  * The JSpec library:
/share/www/script/jspec

  * Custom helpers I need in many of the specs
/share/www/spec/custom_helpers.js

  * The specs!
/share/www/spec/*_spec.js
I've split them in separate files because shorter files are nice. The 
division is more or less random. In general the specs are in the order 
the methods are in their files though.


How JSpec works
~~~~~~~~~~~~~~~

JSpec is a Javascript Unit Testing framework. I chose it because I was 
most familiar with it. JSpec uses a special DSL that doesn't look like 
Javascript, but the syntax is very similar to written english, just try 
to read and understand it :)

Within the JSpec context, every object gets extended with the "should" 
method. Should takes a matcher (eg "eql"). So I can do things like:
var mystring = "a string";
mystring.should.eql "a string"

It also lets you structure your tests nicely: stuff that belongs 
together is put into a "describe" block. The single assertion blocks 
("it should do ...") are executed independently: Things you want to be 
done before or after every "it" block go into a "before_each" or 
"after_each" block within a "describe" block. I use this to delete and 
recreate the database after every assertion, so I really know what's in 
my database currently.

Read more about JSpec here: http://jspec.info/



Trouble shooting
~~~~~~~~~~~~~~~~

  * When you change the specs, but your changes have no effect, manually 
reload the changed spec file in the browser.

  * When the spec that tests erlang views fails, make sure you have 
enabled erlang views as described here:
  <http://wiki.apache.org/couchdb/EnableErlangViews>

  * If you want to run only some of the specs: open 
/share/www/spec/run.html and uncomment the files with the specs you 
don't want to run.


Open Questions and TODOs
~~~~~~~~~~~~~~~~~~~~~~~~

  * Two tests in jquery_couch_js_instance_methods_3_spec.js are failing: 
the query method ignores it when you want to filter for specific keys. 
This works with the query method in couch.js. The ticket is here:

https://issues.apache.org/jira/browse/COUCHDB-726


  * Some methods only exist in jquery.couch.js and not in couch.js: 
signup, copyDoc, bulkRemove, allApps, config, compactView. Ticket:

https://issues.apache.org/jira/browse/COUCHDB-725

If someone wants to implement them (or one of them), I think it's a 
great job for a new contributor. It's mostly copy and paste and a bit of 
thinking. If you are a unsure of how to write the tests for it, I'm 
happy to help.


  * One thing that stands out is that even though the methods in both 
files have the exact same outcome, they are named differently:

info/getVersion, save/saveDoc, deleteDoc/removeDoc, open/openDoc, 
deleteDb/drop, createDb/create.

I know it's like that because both files have been written by different 
people. I'm not in favor of either spelling, but I think the methods 
eventually should have the same names in both files. I guess it's better 
to do that as long as we're officially in beta. What do you think?


  * TODO: Futon integration, as described above.


Thanks for reading.
Lena



Mime
View raw message