Running unit tests on JavaScript code from XUL - what and how

I am writing an XUL application. This is not a Firefox extension, but a standalone application that will be used through XULrunner. My intention is to accept TDD in my development process, and I am looking at RhinoUnit as a unit testing framework. I will try to use it anyway, but the documentation for XUL applications is scarce. Some people talk about using UxU - but only for Firefox add-ons - and Mochitest - if you want to test only Mozilla.

My question is: did someone write some XUL application with unit tests? What tool did you use, and if it is someone I mentioned, how did you use it?

+8
javascript unit-testing xul rhino rhino-unit
source share
2 answers

You can try to take a look at Mozmill . This is an addon that can be used to test all Gecko-based applications.
You can use it to check the interface of your application’s interface.
The documentation is fine, and if you have any questions, you can try the dedicated mailing list.

+1
source share

I have been successfully using Mochitest for an add-in, it should be used in the XULRunner application in basically the same way. You need the files under http://hg.mozilla.org/mozilla-central/file/tip/testing/mochitest/ , use the "zip" link to download the contents of the directory. Put these files somewhere in your project and map this directory to chrome://mochitest/content/ . Put your tests in the chrome/ subdirectory, when writing these tests extensive documentation . You can use runtests.py with the runtests.py command line --chrome to run the tests, but I doubt it would be possible without setting up a script. Opening chrome://mochitest/content/harness.xul in your application (in the form of an XUL dialog or by specifying -chrome chrome://mochitest/content/harness.xul on the command line) should also be done.

Edit : I was wrong, the "zip" link loads the entire repository. I do not know how to get a specific directory from the repository, then the fastest solution is to run hg clone http://hg.mozilla.org/mozilla-central/ from the command line to get a copy of the entire repository.

+1
source share

All Articles