作为这个问题的后续,我正在尝试 MozMill 来测试独立的 XUL 应用程序(不是 firefox 扩展)。但是,我还没有“明白”——更具体地说,是如何测试基于 XULRunner 的应用程序。
例如,考虑这个应用程序。现在,我可以从命令行运行它,或多或少这样:
$ /path/to/xulrunner /full/path/to/mozmillexample/application.ini
我想编写 Mozmill 脚本来测试它。例如,我想写一个像这样的测试,它具有单元测试的“味道”:
Components.utils.import("chrome://mozmillexample/content/example.js", example);
var setupModule = function(module) {
module.controller = mozmill.getBrowserController(); // Or what?
}
var testEquals = function() {
jumlib.assertEqual(example.exHello(), "Hello, World!", "Should be equal");
}
我也想写一些功能测试:
Components.utils.import("chrome://mozmillexample/content/example.js", example);
var setupModule = function(module) {
module.controller = mozmill.getBrowserController(); // Or what?
}
var testAlerts = function() {
var button = findElement.Elem(document.getElementById('button'));
button.click();
controller.window.assertAlert(); // I bet it does not exist but it gives the idea...
}
然而不幸的是,我没有找到任何关于测试独立应用程序的文档,至少没有一个解释基本步骤的文档。所以我问:是否可以编写像这样的测试?如果可能的话,我该怎么做?