Running unit tests of JavaScript code from XUL - what and how
Asked Answered
C

2

8

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

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

Childress answered 23/7, 2011 at 1:17 Comment(0)
D
1

You could try to have a look at Mozmill. It is an addon that can be used for testing all Gecko based applications.
You can use it to test UI interface of your application.
The documentation is quite ok and if you have any question you can try the dedicated mailing list.

Demure answered 27/7, 2011 at 15:35 Comment(2)
Mozmill may be a great solution but I just could not make it work for me. I have ever asked another question but no success. Do you have some hidden documentation about using MozMill the way I need? Could you describe a bunch of simple steps to use it?Childress
Have you tried installing the Mozmill extension in your xulrunner application? Once you've installed it, you just need to create a simple test like described here. And launch it fromn the Mozmill extension window.Demure
P
1

I am successfully using Mochitest for an add-on, it should be usable in a XULRunner application in mostly 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 directory contents. Put these files somewhere in your project and map this directory to chrome://mochitest/content/. Put your tests into the chrome/ subdirectory, there is extensive documentation on writing these tests. You could use runtests.py with --chrome command line options to start the tests but I doubt that this will be possible without tweaking the script. Opening chrome://mochitest/content/harness.xul in your application (as a XUL dialog or by specifying -chrome chrome://mochitest/content/harness.xul on the command line) should do as well.

Edit: I was wrong, the "zip" link downloads the entire repository. I don't know of any way to get a particular directory from the repository then, fastest solution should be running hg clone http://hg.mozilla.org/mozilla-central/ from the command line to get a copy of the entire repository.

Pup answered 10/8, 2011 at 16:37 Comment(1)
Thank you for the answer and the edition. I figured something was wrong when it was taking an entire hour to download the zip :) Anyway, I will test your suggestion as soon as possible and will inform about the result.Childress

© 2022 - 2024 — McMap. All rights reserved.