加载 Resharpers QUnit testrunner 的支持脚本
我一直在使用 QUnit 在我的 Visual Studio 11 解决方案中测试一些 javascript,最近更新了 Resharper,在其测试运行器中支持 QUnit。
当我之前手动运行测试时,我会加载 html 页面,该页面加载要测试的 javascript 以及 qunit.js。我的 javascript 将加载并运行一些初始化/支持代码,这是一切正常工作所必需的。
在 resharper 中,我发现脚本没有运行,因此我的许多测试都失败了。
解决这个问题的最佳方法是什么?
I've been using QUnit to test some javascript in my Visual Studio 11 solution and recently updated Resharper that supports QUnit in its testrunner.
When i manually ran the tests before, i would load the html page that loads my javascript to be tested as well as the qunit.js. My javascript would load - and run some initializing/support code which is required for everything to work.
In resharper i find that the scripts are not run and thus, many of my tests fail.
What would be the best way of solving this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,看来我对 ReSharper 中的问题无能为力,直到他们添加了修改 html 的功能。
与此同时,我从 http://www.phantomjs.org/ 得到了一些帮助,这是一个框架运行无头浏览器。这样我就可以制作一个不需要 UI 的脚本来进行测试 - 这里甚至还有一个 QUnit 的运行程序 http://code.google.com/p/phantomjs/wiki/ServiceIntegration#QUnit_Driver
这样我就可以在 CI 环境中运行测试了。
目前来说,这应该已经足够好了……
Ok, it seems there isn't much i can do about the problem in ReSharper till they add the feature of modifying the html.
I the mean time i had a little help from http://www.phantomjs.org/ which is a framework to run a headless browser. With that i can make a script that needs no UI, that does the testing - there is even a runner for QUnit right off the bat here http://code.google.com/p/phantomjs/wiki/ServiceIntegration#QUnit_Driver
With that I'm able to run the tests, also in a CI environment.
That has to be good enough for now...
对于在搜索中发现此问题的其他人,另一个选择是在 Resharper 中禁用 Qunit 测试。 (显然,使用 PhantomJS 运行测试是一个“更好”的解决方案,但如果您需要继续移动,这将使您的其他测试仍然通过 Resharper 执行。)
在 Resharper 7 中,您可以通过访问 Resharper 菜单/选项来执行此操作。然后找到“工具”子标题并展开其下的“单元测试”节点。应该有一个名为“JavaScript Tests”的节点。选择该选项,然后取消选中“启用 QUnit 支持”复选框。保存更改,然后尝试在 Resharper 中重新运行测试。
执行此操作后,Resharper 将不再在要执行的测试列表中选取 Qunit 测试。
For anyone else finding this question in a search, another option would be to disable Qunit tests in Resharper. (Obviously running the tests with PhantomJS is a 'better' solution, but if you need to keep moving, this will let your other tests still be executed via Resharper.)
In Resharper 7, you can do this by accessing the Resharper Menu / Options. Then locate the Tools sub-heading and expand the 'Unit Testing' node under that. There should be an node named 'JavaScript Tests'. Select that and then uncheck the 'Enable QUnit support' checkbox. Save your changes and then try to re-run your tests in Resharper.
After doing this, Qunit tests will not longer be picked up by Resharper in the list of tests to execute.