Changes

Jump to: navigation, search

Unit Testing

2,286 bytes added, 21:49, 13 December 2006
What I have learned
== Project Contributor(s) ==
* [[User:Vpmirand|Vanessa Miranda]] (vanessa)** Helped to layout the test window.
* [[User:David.humphrey|Dave Humphrey]] (dave or humph)
** Connectted me to Mozilla test team and gave me great links.
* Rob Campbell
** Helped me to detail the requirements of unit testing framework
== Project Details ==
* Spent a whole day on trying to debug bookmark services in firefox API... no documentation... man ===, so frustrating.* ...* Gave up debugging bookmark services API, continued working on framework.
=== November 20, 2006 ===
* The source Coding core code can be download here [http://paulgu.com/download/mozilla/unittesting@paulgu.com.xpi Unit Testing of the framework].
=== December 06, 2006 ===
* Code documentationFinished core code of the framework.* Instruction Documenting code.* Writing instruction on how to write test cases by using this framework
=== December 07, 2006 ===
* Finished documentation of the framework
=== December 10, 2006 ===
* Updated the core code of the framework, cleaned debugging code.
* Optimized some functions.
{{clear}}
 
== Unit Testing Framework for Firefox ==
The files starting with is the core framework files.
* unittesting.js, holds the unit test cases that need to be tested.
* unittestingDisplay.js, is responsible for displaying message to UItesting window.
* unittestingLog.js, is responsible for logging message to the error console or log file.
* unittestingOverlay.js, is responsible for populating the GUI window.
* unittestingWindow.js, holds all the unit testing functions
* unittestingWindow.xul, is responsible for loading the framework and updating UI test window elements.
{{clear}}
=== How to add write 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 setps. (This example is for bookmarks unit testing)
==== Step 2. A Write a test suite holding variable called suite that holds all the your test cases. ==== The following is example of bookmarks test suite. In suite, you could have a setUp() for preparing unit testing, and you could have a tearDown() to clean up after unit testing. The framework will execute them automatically in sequence.
The following is example of bookmarks In each test suite. In suitecase, you could have a setUp() for preparing unit testing, and you could have a tearDownneed to run assert() to clean up after unit testing. The framework will execute them automaticallycheck the test result.
<pre>
=== Customize Extension Menu Item Name ===
If users want to change the menu item namefor a specific test case, they can open file '''unittesting.dtd ''' under folder '''local'''.
[[image:extension02.png|600px]] <br />
And then they can change the first item to your test case name in the file unittesting.dtd.
[[image:extension03.png|600px]] <br />
=== Run the tests ===
After adding the test cases to the extension, the participant can install the extension by drag and drop the extension into Firefox, and they could see then click on install to install the following screen in Firefoxunit testing framework with your test cases.
Running test cases is also easy, user can click on '''Tools''' menu from Firefox, and you will see an extension called '''Unit Testing for [[image:extension01.png|600px..]] <br />'''.
Select the Unit Testing, system will pop up the test window as following[[image:extension01.png|602px]] <br />
[[image:extension04.png|600px]] <br />
Users can also open Select the error console window to watch all testing logs'''Unit Testing for [... Here is ]''', system will pop up the console following testing window.
[[image:extension05extension04.png|600px602px]] <br />
Now click on the run button on test window. All logs will be displayed in console.
[[image:extension06Now click on the run button on test window, the test result will be displayed on test window.png|600px]] <br />
Unfortunately, the test windows cannot be displayed, because it hasn't been developed[[image:extension07.png|602px]] <br />
[[image:extension07.png|600px]] <br />
Further more, user can run test cases as many times as they want, and the result will be populated on test window as well.
 
[[image:extension08.png|602px]] <br />
 
{{clear}}
 
=== Unit testing log ===
Right now, this framework provides a detail log for test running. This will allow users to track the detail testing process and any error that encountered during the testing.
 
In order to check the error console, go to '''Tools''' menu in Firefox, and select '''Error Console'''.
 
[[image:extension05.png|602px]] <br />
 
 
After push the '''Run''' button, the testing process message will be displayed in console.
 
[[image:extension06.png|602px]] <br />
 
 
Notice: The framework runs the setUp() first, which we can see the highlighting in the screen shot.
 
[[image:extension06-1.png|602px]] <br />
 
 
Notice: The framework runs the tearDown() when all the test cases are finished, which we can see the highlighting in the screen shot.
 
[[image:extension06-2.png|602px]] <br />
 
{{clear}}
=== What I have done ===* Core code and structure of the framework as an extension, and make writing test case as easily as I canpossible. It's similar as writing JUint test cases.
* Testing window layout
* Test result on testing window
* Displaying logs in the error console
* Instruction on how to write test cases by using this framework(readme.txt)
{{clear}}
=== What need to be continued ===
* Better layout displayed on of testing window if you have innovative idea
* Write log into file for further analyzing by Mozilla
* Improve the structure of the framework and make it more easier for users if you could
{{clear}}
=== What I have learned ===
Based on my experice in open source developing, I had a lot of fun for doing it. Also I'd like to address some improtant comments when we I was working on the open source.
* It was very time-consuming. Confidence and patience are the key to success. : This project has no prototype or even any example; most of time I couldn't get help because very less people work on this; and different people will do a different way in unit testing. It took me a lot of time to do researching, trying, and debugging. It also needs a lot of patience; if one way doesn't work, you still need to keep working on it until find the solution. You can take a short break and a deep breath, but never give up.* Documentation. : Any code we wrote should be documentated. It's very important for you to check back and for the people who want to contrubute to it.This is really important in open source community. Because I couldn't find the documentation for the Bookmarks services, I cannot make the bookmark unit testing work.* You need to get help from the others, but don't wait. : I had sent email to ask help for my problems, and I never get response. Especially It's kind of wasting time. You need to move on, especially in open source community, we do need help from the others, but don't relay on them.
{{clear}}
== Project News ==
* Sunday, December 10, 2006 9:45 am, finished core code and structure of Unit Testing Framework for Firefox.
* Wednesday, September 20, 2006 1:07 pm, Rob helped me to get start on JSUnit Testing.
1
edit

Navigation menu