Changes

Jump to: navigation, search

Unit Testing

350 bytes removed, 10:05, 10 December 2006
How to add test cases by using this framework
=== How to add test cases by using this framework ===
Writing the test cases by using this framework is really easy. All you need to to is opening the file '''unittesting.js''', and add any type of test case by adding following three sectionssetps. (This example is for bookmarks unit testing)
* Section ==== Step 1. Initialize the services (Firefox API) ====This step initializes the services that contains all the units that are going to be tested. The following is the example of bookmarks services in Firefox API.
<pre>
*
* In this part, you need to initialize the services that contains all the units
* * EXAMPLE: initialize This is an example for Bookmark Service * this._RDF = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService); * this._kBMSVCIID = Components.interfaces.nsIBookmarksService; * this._BMDS = this._RDF.GetDataSource("rdf:bookmarks"); * this._BMSVC = this._BMDS.QueryInterface(this._kBMSVCIID);Services
*
---------------------------------------------------------------------------*/
* bookmark test window initialization
*
* setUp is for initializing services in the firefox API
*
---------------------------------------------------------------------------*/
var bookmarkstestWindow = {
pass: true,  setUpinitialize: function() {
logText("Unit Testing Window startup");
this.bookmarksTests = new BookmarksTests(); // initialize bookmark unit tests
this.testsRun = new Array();
logText("finished unit testing startup");
},
 
tearDown: function() {
}
};
*
---------------------------------------------------------------------------*/
window.addEventListener("load", bookmarkstestWindow.setUpinitialize, false);
</pre>
1
edit

Navigation menu