使用 MozMill 测试独立的 XUL 应用程序 [英] Using MozMill for testing standalone XUL applications

查看:42
本文介绍了使用 MozMill 测试独立的 XUL 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为这个问题的后续,我正在尝试使用 MozMill 来测试独立的 XUL 应用程序(不是 firefox 扩展).但是,我还没有明白" - 更具体地说,如何测试基于 XULRunner 的应用程序.

As a follow-up of this question, I am trying MozMill for testing standalone XUL applications (not a firefox extension). However, I did not "get it" yet - more specifically, how to test a XULRunner-based application.

考虑 ,例如.现在,我可以从命令行运行它,或多或少这样:

Consider this app, for example. For now, I can run it from command line, more or less this way:

$ /path/to/xulrunner /full/path/to/mozmillexample/application.ini

我想编写 Mozmill 脚本来测试它.例如,我想写一个这样的测试,它具有单元测试的味道":

I would like to write Mozmill scripts to test it. For example, I would like to write a test such as this one, which has as "taste" of unit testing:

 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");
}

我也想写一些功能测试:

I would like to write some functional tests, too:

 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...
}

然而,不幸的是,我没有找到任何关于测试独立应用程序的文档,至少没有解释基本步骤.所以我问:是否可以编写这样的测试?如果可能,我该怎么做?

Unfortunately, however, I did not find any documentation about testing standalone apps, at least none explaining the basic steps. So I ask: is it possible to write tests like these ones? How could I do it, if it is possible?

推荐答案

我让它与 MozMill 扩展一起工作;解压扩展并编辑以下文件:

I got it to work with the MozMill extension; unpack the extension and edit the following files:

  • 将此添加到 install.rdf 的正确位置:

  • add this to install.rdf at the right place:

<em:targetApplication>
  <Description>
    <em:id>mozmill@example.com</em:id>
    <em:minVersion>0.9</em:minVersion>
    <em:maxVersion>1.1</em:maxVersion>
  </Description>
</em:targetApplication>`

  • 在应用程序的根目录中创建一个文件夹extensions"(application.ini 和chrome"以及defaults"文件夹所在的位置);将解压的 mozmill 扩展粘贴到那里.

  • create a folder "extensions" in the application's root (where application.ini and the "chrome" and the "defaults" folder are); paste the unpacked mozmill extension there.

    启用扩展管理器,如MDC

    在您的 XULRunner 应用中嵌入 MozMill 扩展代码:<script src="chrome://mozmill/content/overlay.js"/>

    embed the MozMill Extension code in your XULRunner app: <script src="chrome://mozmill/content/overlay.js"/>

    通过添加或修改%appdata%\Adam Brandizzi\MozMill Example\Profiles\123455.default\extensions.ini 来启用扩展:[扩展目录]Extension0=C:\Users\John\Desktop\myXULApp\extensions\mozmill

    • 使用以下JS代码打开MozMill:MozMill.onMenuItemCommand(event);

    这篇关于使用 MozMill 测试独立的 XUL 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆