Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set breakpoints in my qunit tests when using the Resharper test runner

It's a great thing that with Resharper 6 one can write qunit tests and run those with the integrated resharper test runner. However, I wonder if it is possible to set breakpoints in the tests and the code under test. The problem is, each time it opens the browser it uses a different randomized port number which means you can not just set breakpoints in the browser and rerun the tests by hitting F5. So I wonder, is it even possible somehow?

like image 699
Christoph Avatar asked Dec 10 '11 21:12

Christoph


People also ask

How do you add a breakpoint to a test?

To add a regular breakpoint to a test step, right-click the step or action and select Break while executing step. For a transition, point to the transition, click the gear icon , and select Break when transition taken. A red icon indicates a regular breakpoint.

How to run unit tests with ReSharper?

Ctrl+U R / Debug Unit Tests. Ctrl+U D on the toolbar. To run all tests in the session, click Run Current Session. Ctrl+U Y on the toolbar or alternatively, choose ReSharper | Unit Tests | Run Current Session from the main menu.


2 Answers

If you are using Firefox with the Firebug plugin, you can do this: add a debugger statement to your code where you want to break:

var x = 2;
debugger;
...

Set the Firebug option 'Active for all Web Pages' to true. In ReSharper options, Testing>JavaScript set Firefox as the browser to use (if it is not already your default).

Now Firebug debugger will break at the debugger statement.

PS I tried this with Chrome but couldn't get it to break. Anyone know how to do it?

like image 147
Rob Kent Avatar answered Oct 23 '22 19:10

Rob Kent


Unfortunately, it is not possible at the moment - see this request. What I suggest you do right now if you need debugging is to use QUnit canonically - create an HTML page, drop your JS libs, tests and QUnit into them, and put in the QUnit HTML elements to display the results. This way, you'll be able to set breakpoints in JS.

like image 39
Dmitri Nesteruk Avatar answered Oct 23 '22 18:10

Dmitri Nesteruk