带有单元测试的 JavaScript RIA 示例
谁能给我提供带有单元测试的大型 JS 应用程序(包括 AJAX、不同的 UI 小部件和复杂的架构)的示例?
我不是在这里谈论 Selenium 测试,只是使用模拟的简单愚蠢的单元测试,体面的结果报告等等。
不知道为什么人们投票结束,或者否决了这个问题。也许评论会很好。 说真的,我一直在努力寻找经过单元测试的网络应用程序,因为我很难构建模拟,而且我想知道是否可以通过合理的努力来实现。它让我思考与 Selenium 测试相比,小部件单元测试的好处。人们在理论上对单元测试喋喋不休,但显然没有人真正在 JS-RIA 中做到过。或者他们有吗?
Can anyone give me examples of large-scale JS apps (including AJAX, different UI widgets, and a sophisticated architecture) with unit tests?
I'm not talking about Selenium tests here, just plain ol' stupid unit tests using mocks, decent result reporting and such.
Not sure why people voted to close, or downvoted the question. Maybe a comment would be nice.
Seriously, I've been trying hard to find unit tested web apps, since I'm having a hard time building mocks and I wonder if it's even possible with reasonable effort. It made me think about the benefits of unit tests on widgets as compared to Selenium tests. People are babbling a lot about unit tests in theory but evidently nobody actually has done it in JS-RIAs. Or have they?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
就我个人而言,我喜欢 Qooxdoo,您自己检查一下,看看这是否是您想要的
http://qooxdoo.org/demo#real-life_examples
Personally I like Qooxdoo, check it out for your self and see if this is what you want
http://qooxdoo.org/demo#real-life_examples
这是一个很好的工具:http://www.uize.com/
This is one good tool: http://www.uize.com/
你应该看看《茉莉花》和《茉莉花》。 Sinon.js : http://sinonjs.org/
这是一个关于使用 Backbone.js、Jasmine 和amp 进行测试的很好的教程; Sinon.js : http://tinnedfruit.com /2011/03/03/testing-backbone-apps-with-jasmine-sinon.html
我还推荐 Phantom.js 进行集成测试...一个无头浏览器,比使用 Selenium 快得多... http://www.phantomjs.org/
顺便说一句,这里是来自 Pivotal 的经过单元测试的应用程序示例:https://github.com/pivotal/cimonitor。您可以在那里找到客户端测试 ->
cimonitor/public/javascripts/js-common
You should look at Jasmine & Sinon.js : http://sinonjs.org/
Here is a good tutorial on testing using Backbone.js, Jasmine & Sinon.js : http://tinnedfruit.com/2011/03/03/testing-backbone-apps-with-jasmine-sinon.html
I also recommend Phantom.js for integration testing... It's a headless browser and much faster than using Selenium... http://www.phantomjs.org/
Btw here is an example of unit-tested app from Pivotal : https://github.com/pivotal/cimonitor. You can find client-side tests there ->
cimonitor/public/javascripts/js-common
我不确定这个答案是否合格,但我正在研究我的宠物项目“Atomic OS”(网络开发人员的操作系统隐喻)的下一个迭代,它最终将满足您的标准。
我正在开发一个相关项目(目前还不能分享),该项目构建在基本的 Atomic OS v2 基础上,并为移动 Web 应用程序提供了一组丰富的 UI 小部件。
我建造了&使用 JSDog 从 JSDoc 语法的子集生成文档,并使用 QUnit。
有关我打算进行单元测试的示例,请参阅 原子操作系统文档。 (点击任务栏中的“Docs”,选择一个类,如 HxJSFS)
I'm not sure if this answer will qualify but I'm working on the next iteration of my pet project "Atomic OS" (an OS-metaphor for web developers) which will, eventually, meet your criteria.
I'm working on a related project (which I can't share just yet) that is built on a bare-bones Atomic OS v2 foundation and provides a rich set of UI widgets for mobile web apps.
I built & use JSDog to produce documentation from a subset of JSDoc syntax and unit test runners with QUnit.
For an example of where I'm intending to go with unit tests, please see the Atomic OS documentation. (Click "Docs" in the taskbar and select a class, such as HxJSFS)
只是一个观点:
我正在开发一个 Web 应用程序,它是视频分析系统的前端。 (后端通常是 IP 摄像机、DVR 或运行非常非常精简的嵌入式 Web 服务器的视频路由器。)它使用许多 jQueryUI 小部件,允许用户配置设备、创建视频分析规则并在其上绘制标记使用画布元素的视频帧。我认为它相当复杂。
我们对非常有限的代码子集使用单元测试(最初是为 JSUnit 编写的,但现在使用 qunit)。我们通过单元测试来验证业务对象的行为,包括序列化到 XML 或从 XML 反序列化的能力。我们有单元测试来测试我们为画布标记编写的基本几何类。
但是,我们没有可以操作 DOM 或验证页面上的元素是否处于正确状态的单元测试。正确地做到这一点让我们觉得这个问题太难解决,因此我们依靠 Selinium 测试来验证给定的一组输入是否会将 DOM 置于正确的状态。
Just one perspective:
I work on a web application that is the front end of a video analytics system. (The back end is typically an IP camera, DVR or video router running a very, very lean, embedded web server.) It uses a number of jQueryUI widgets, allows user to configure the device, create video analysis rules, and draw markup over video frames using canvas elements. I think of it as fairly sophisticated.
We use unit tests (originally written for JSUnit, but now using qunit) for a very limited subset of the code. We have unit tests to verify the behavior of business objects, including the ability to serialize/deserialize to/from XML. And we have unit tests to test the basic geometry classes we've written for the canvas markup.
However, we have no unit tests that manipulate the DOM or that verify that the elements on a page are in the correct state. Doing that correctly struck us as too difficult a problem to solve, so we rely on Selinium tests to verify that a given set of inputs will put the DOM into the correct state.