Lorcan McDonald from the IBM XPages development in Dublin has posted a unit test framework for XPages – see here.
To test functions with the framework you create an object with one or more testcase functions as properties of that object. A testcase is any function starting with the string ‘test’. A suite should also have a name property to help identify it in the test results. To run the tests you pass the function into the UnitTesting.runSuite() function (UnitTesting is defined in an external file).
Here is a simple sample test suite that tests the built-in Math.abs() function:
var testSuite = new function()
this.name = ‘Math Tests’;
this.testAbs = function(unitTester)
unitTester.assertEquals(Math.abs(-1), 1, ‘Incorrect conversion’);