On Sun, Feb 15, 2009 at 02:15:57AM +0100, Jan Lehnardt wrote: > Hi, > > I prepared a patch that adds EUnit-style tests to CouchDB: > > http://friendpaste.com/2DAOEki94jg8SGfxheh769 > > The patch currently simply disables all tests that were available > in the ./test/ directory. The `couch_config_*` tests have been > migrated to the new EUnit style. The command-line based > JS test suite has yet to be enabled again. This is trivial. > > The patch touches Makefiles'nstuff. Here's how to use it: > > make local-clean > ./bootstrap > ./configure > cd test > make test > > You should see (after a while): > > ... > /usr/local/bin/erlc -o ../src/couchdb/tests/ ../src/couchdb/tests/*.erl > erl -noshell -pa ../src/couchdb/ -pa ../src/couchdb/tests/ \ > -eval "eunit:test([couch_config, couch_config_writer])" \ > -s init stop > All 8 tests successful. > > The output can be beautified. I kept it raw to show all that happens. > > You see that this is still contained to the ./test/ directory. We'd > still > need to hook it up to the top level `make test`. I hope to get some help > with this. > > Also, the conditional compilation with `erlc -DTEST` is not ideal yet. > I chose to use this to keep all test code out of code that will be > deployed, > but currently, all compiled `.beam` files get `rm`'d and recompiled with > `erlc -DTEST` on every test-suite run. Also, if you happen to run `make > install` from the top level directory, you'd install the test-enabled > beam > files. My lack of Autotools-fu prevented me from doing this more > elegantly > and again, I hope to get some help from the community. > > -- > > Writing Tests > > Hey, nice, you stuck around and like to know how to write tests now? > Easy: > > 1) Create a file `my_module_tests.erl` in src/couchdb/tests/ e.g. > `couch_config_tests.erl`. > > 2) Insert boilerplate header: > > -module(my_module_tests). > > -include_lib("eunit/include/eunit.hrl"). > > 3) Start writing tests. See > http://svn.process-one.net/contribs/trunk/eunit/doc/overview-summary.html > for details. You can take the couch_config*_tests.erl files as guide, > but they are of poor quality and not yet good EUnit style. I tried to > change > as little as possible with this patch. > > 4)* Add my_module in line 28 of test/Makefile.am > > 5) cd test && make test > > 6) Go to step 3). > > * This should be made more elegant as well as more test suites > are written. > > -- > > What do you think? > > Cheers > Jan > -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
From reading your description, wonderful. ~M >
