baudehlo/Haraka — pull request #164 by godsflaw (2012-02-17 00:43:50+00:00)
Title: New unit testing with nodeunit and a log.syslog change

I've added a git submodule of nodeunit to haraka, and two tests for relay_all and log.syslog plugins so that people can get an idea of how to test with nodeunit. There will be many more test to come in the future, both for plugins and core modules.

I've also added some helpful code for testing in function-bind.js. This should allow one to modify anonymous functions in haraka, or in tests, with .bind(this), thus scoping the caller's 'this' object to the anonymous function.

When testing plugins, core modules are usually stubbed out due to the more complex nature of how haraka runs plugins. While not all core module stubs are present or even complete, I do expect we will fill them out as needed.

To run these tests simply type ./run_tests from the haraka root. If the submodules are not yet installed it will prompt you to run the two submodule commands: 'git submodule init' and 'git submodule update'. One only has to do this once to get the submodule.

The nodeunit submodule is pulled from a slightly hacked version of nodeunit I made to add a bunch of additional asserts. I've submitted these changes to the nodeunit author as a pull request in the hopes that we can simply submodule the mainline nodeunit in the future. One can see the pull request here:
https://github.com/caolan/nodeunit/pull/153