开发者

Loading support script for Resharpers QUnit testrunner

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 jav开发者_StackOverflow中文版ascript 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?


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜