All
All
Projects
Snippets
Go
Explore
Home
About
Get Involved
IP
Legal
Interact With Us
Blog
Webinars
Discord
Twitter
YouTube
Facebook
OpenNTF GitHub
OpenNTF Connections GitHub
IBM Connections Downloads
DominoHelp (external)
Explore
Home
About
Get Involved
IP
Legal
Interact With Us
Blog
Webinars
Resources
Discord
Twitter
YouTube
Facebook
OpenNTF GitHub
OpenNTF Connections GitHub
IBM Connections Downloads
DominoHelp (external)
Resources
Discord
Twitter
YouTube
Facebook
OpenNTF GitHub
OpenNTF Connections GitHub
IBM Connections Downloads
DominoHelp (external)
Projects
Snippets
Collaboration Today
Sign In
Username
Password
Forgotten your login credentials?
Login
Register
All
All
Projects
Snippets
Go
Unit tests for XPages
Posted by
Niklas Heidloff
on
April 24, 2009
OpenNTF has a new framework to do unit tests for JavaScript in XPages.
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:
(function(){
var testSuite = new function()
{
this.name = 'Math Tests';
this.testAbs = function(unitTester)
{
unitTester.assertEquals(Math.abs(-1), 1, 'Incorrect conversion');
}
}
UnitTesting.runSuite(testSuite);
})();
Here are the sample results of the sample unit
test
in the NSF:
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus