Differences between revisions 5 and 6
Revision 5 as of 2011-11-23 15:13:11
Size: 2098
Editor: 62
Comment: add ContributorGroup link
Revision 6 as of 2018-12-17 19:28:26
Size: 0
Editor: JoanTouzet
Comment: Obsolete info, no longer valid
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:

== Summary ==
This page focuses on how to create a test case for couchdb and run it. Creating failing test cases to identify a problem is a great way to contribute to couchdb.

== Context ==
 * You run the tests via clicking in your browser
 * The tests require the server to be running
 * All tests exist in one file:
  * (couch source)/share/www/script/couch_tests.js
  * tests are js functions and begin with: foo: function(debug)
 * Running tests this way may seem awkward at first
  * But the process is pretty quick
  * I can modify a test and see the results within a few seconds
 * This page assumes you've built couchdb from source

== To run the existing tests ==
 * Go to: http://localhost:5984/_utils
 * Click: Test Suite
 * Click: the triangle button next to the test you want to run

== When a test is failing ==
 * Currently the tests only run correctly in Firefox.
 * When a test is failing, re-run the single test repeatedly.

== To create a new test ==
 * Either:
  * Go to
  * Start writing your test case
  * Click "Run" to run it.
  * To make this test case permanent, do this:
 * Or:
   * Go to: (couch source)/share/www/script/couch_tests.js
   * Either:
    * Add lines to an existing test
    * Create a new test in the 'tests' hash

== Steps to run your test ==
 * 1: Run this command from your couchdb source dir
  * sudo make install
 * 2: Run the tests in your browser or on the command line (master > 1.2):
  * Browser:
   * reload first
   * see 'To run the existing tests' heading above
  * CLI:
   * ./test/javascript/run (run all tests)
   * ./test/javascript/run foo (run test "foo")

== Example ==
I added these lines to the 'lots_of_docs' method, to make the test fail:

     // Check _all_docs with descending=true again (now that there are many docs)
     var desc = db.allDocs({descending:true});
     T(desc.total_rows == desc.rows.length);

Then I attached the diff to an existing Jira bug that described the issue.