针对不同浏览器的 Javascript 代码的持续集成/测试

发布于 2024-10-05 18:28:33 字数 274 浏览 4 评论 0原文

我正在用 Javascript 编写一组函数,旨在在浏览器内执行(无服务器端 Javascript)。

如何在不同的浏览器中运行单元和性能测试,并跟踪每个构建的结果?

  • 测试应在浏览器中执行
  • 测试结果应作为独立的文本或 html 文件生成
  • 目标浏览器是 Internet Explorer 7 和 8、最新的 Firefox、最新的 Chrome、最新的 Safari
  • 我可以自由设置专用的 CI 服务器和虚拟机,如果需要的

I am writing a set of functions in Javascript meant to be executed inside a browser (no server-side Javascript).

How to run unit and perfomance tests agains them in different browsers, and keep track of the results for every build?

  • Tests should be executed within a browser
  • Test results should be produced as a stand alone text or html file
  • Target browsers are Internet Explorer 7 and 8, latest Firefox, latest Chrome, latest Safari
  • I am free to setup a dedicated CI server and virtual machines if needed

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

又怨 2024-10-12 18:28:33

我一直在使用 Jasmine 框架和 JSTestDriver 进行测试。作为评估的一部分,我还为 CI 设置了 Hudson 和 TeamCity,但最终选择了 TeamCity。

Jasmine 是一个非常好的 BDD 框架,它还提供了模拟和存根功能。

JSTestDriver 服务器允许任何浏览器连接到它,无论是本地还是远程,正如 Vojta 已经指出的那样。例如,我已经能够连接 Windows 和 MAC 机器以及 iPhone 上的浏览​​器……如果移动开发激起了您的兴趣,那么连接其他移动浏览器是很有可能的。 JSTestDriver 将生成 Hudson 或 TeamCity 能够解析和报告的 JUnit XML 结果文件。

正如 Vojta 还指出的那样,JSTestDriver 可以使用 Eclipse 插件。我最近转向了 WebStorm 1.0,现在转向了 2.0(来自 JetBrains 的 IDE),并且该 IDE 也存在一个插件,尽管有些问题。顺便说一句,就 JavaScript 开发而言,WebStorm 非常出色。

我们也在编写服务器端 JS 代码,Jasmine 在这里也运行得很好。

例如,我已在 Amazon 云上安装并配置了 JsTestDriver/TeamCity,并且能够无头运行 Jasmine 测试。

简而言之,在 3 个解决方案(Jasmine、JSTestDriver 和 TeamCity)之间,存在大量允许任意数量的设置或配置的插件/适配器/配方。这并不是说其他​​组合不起作用......简单地说,对我来说,这种组合到目前为止已经证明了自己。

I have been using Jasmine framework for the testing and JSTestDriver. I had also set up both Hudson and TeamCity for CI as part of evaluation, though eventually settled on TeamCity.

Jasmine is a very nice BDD framework, which also provides mocking and stubbing functionality.

JSTestDriver server allows any browser to attach to it, whether local, or remote, as Vojta has already pointed out. I have been able to connect browsers from Windows and MAC machines for example, and also iPhone ... it is quite possible to connect other mobile browsers, if mobile development tickles your fancy. JSTestDriver will produce JUnit XML results files that either Hudson or TeamCity will be able to parse and report upon.

As Vojta also pointed out, an Eclipse plugin is available for JSTestDriver. I have recently moved over to WebStorm 1.0 and now 2.0 (IDE from JetBrains), and a plugin exists for this IDE as well, albeit somewhat buggy. WebStorm is excellent, btw, as far as JavaScript development is concerned.

We are also writing server-side JS code, and Jasmine has worked fine here as well.

I have installed and configured JsTestDriver/TeamCity on the Amazon cloud and I am able to run Jasmine tests headlessly, for example.

In short, between the 3 solutions (Jasmine, JSTestDriver, and TeamCity), tons of plugins/adapters/recipes exist that allow any number of setups or configurations. That is not to say other combinations will not work ... simply, for me, this combinations has proven itself thus far.

难以启齿的温柔 2024-10-12 18:28:33

你好,你可以看看 JQunit,一个基于 JQuery 的 javascript 单元测试框架。此处提供 http://code.google.com/p/jqunit/

Hi you may take a look a JQunit, a javascript unit testing framework based on JQuery. Available here http://code.google.com/p/jqunit/

娇纵 2024-10-12 18:28:33

Jasmine (http://pivotal.github.com/jasmine) 是一个用于测试 JavaScript 的无依赖 BDD 框架。

使用 Jasmine & 会非常容易。 Jasmine Ruby gem 设置针对不同浏览器的运行矩阵(Selenium 驱动 gem 中的浏览器)并按照您的建议通过 CI 报告它们。应该很简单。

Jasmine (http://pivotal.github.com/jasmine) is a dependency-free BDD framework for testing JavaScript.

It would be pretty easy to use Jasmine & the Jasmine Ruby gem to setup a matrix of runs against the different browsers (Selenium drives the browser in the gem) and reporting them via your CI as you suggest. Should be straightforward.

撕心裂肺的伤痛 2024-10-12 18:28:33

我正在使用 JsTestDriver 进行 JS 开发。它是一个测试运行程序(不是单元测试框架),因此您可以将它与 Jasmine 或 QUnit 一起使用。

您只需启动服务器并捕获浏览器(也可以是远程浏览器!),然后通过命令行在所有这些浏览器上运行测试。

Eclipse 也有一个不错的插件。

有关如何设置持续构建环境的详细信息,请参阅 http:// code.google.com/p/js-test-driver/wiki/ContinouslyBuild

I'm using JsTestDriver for JS developing. It's a test runner (not unit test framework), so you can use it together with Jasmine, or QUnit.

You simply start a server and capture browsers (could be remote browser as well !) and then run tests on all these browsers through command line.

There is a nice plugin for eclipse as well.

For more information, how to set up continuous build environment, see http://code.google.com/p/js-test-driver/wiki/ContinuousBuild

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文