Changes

Jump to: navigation, search

Unit Testing

602 bytes removed, 10:08, 10 December 2006
How to add test cases by using this framework
* Section ==== Step 2. A test suite holding all the test cases.==== The following is example of bookmarks test suite.
<pre>
/*
* test suite
*
* This is the test suite that contains all the test cases
* Here is the sample of the bookmarks testing, the following unit will be
* tested:
* testCreateBookmark
* testRemoveBookmark
* testCreateFolder
* testDeleteFolder
* testBookmarkAllTabs
*
---------------------------------------------------------------------------*/
var suite = {
  testManagersetUp: function() { try { }, assertNotUndefined(bookmarksTests._BMSVC); unittestingWindow.passTest tearDown: function("Test Manager"); } catch (e) { Components.utils.reportError("Exception from testManager() : " + e); }
},
*/
testCreateBookmark: function() {
try { var res = bookmarksTests._BMSVC.createBookmark("paulgu.com", "http://www.paulgu.com/", "iso-8859-1", "Paul Yanchun Gu", "", null); // isBookmarkedResource() is not working, // I don't know what type of rSource should be var rSource = "http://www.paulgu.com/";
//check if the bookmark is created successfully var result = true; //assert(bookmarksTests._BMSVC.isBookmarkedResource(rSource)); assert(result, "test Create Bookmark");
if(result == true) {
// if success, testing passed
unittestingWindow.passTest("Create Bookmark ");
} else {
// too bad, testing failded
unittestingWindow.failTest("Create Bookmark ");
}
} catch (e) {
// Exception
Components.utils.reportError("Exception from testCreateBookmark() : " + e);
}
},
*/
testRemoveBookmark: function() {
// need to be developed, this is demo only var result = true; assert(result, "test Remove Bookmark");
},
*/
testCreateFolder: function() {
// need to be developed, this is demo only var result = true; assert(result, "test Create Folder");
},
*/
testDeleteFolder: function() {
// need to be developed, this is demo only var result = false; assert(result, "test Delete Folder");
},
*/
testBookmarkAllTabs: function() {
// need to be developed, this is demo only var result = true; assert(result, "test Bookmark All Tabs");
}
};
* ==== Section 3. Run your test cases. ====In this example, we run bookmarksTeststhat we defined in step 1.
<pre>
/*
1
edit

Navigation menu