running JsUnit tests in the Eclipse browser preview tab.

jsUnit, great tool. thx

I have found that as the eclipse plugin uses the external browser it is has some annoying behaviours, at least for quickly running tests, switch attention to firefox and the ever increasing tabcount was getting old, well rather than complain, here’s the fix i found for my particular probs.

in your test file add the following code

s = (""+window.location).replace("file:///C:...",'localhost');
if (s.indexOf("cacheBuster")<0)
window.location = 'http://localhost/jsunit/testRunner.html?testpage='+s+'&autoRun=true';

this causes the browser preview pane to redirect to the testRunner.html
with the correct query string to load the temp file used in the preview.

the tests then run automatically, very handy. and much less hassle than the eclipse plugin. Super quick,not even a right click just select the preview tab

Initially I was worried as the jsUnitTestSuite.html test failed with the error

Running on Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322)

1. jsUnitFrameworkUtilityTests.html:testStackTrace failed

Expected doStackTraceTest
> doStackTraceTest
> doStackTraceTest
> doStackTraceTest
> testStackTrace
> (String) but was doStackTraceTest
> (String)

Stack trace follows:
> JsUnitException

but this actually fails anyway on my setup under IE7 (works fine in firefox though)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s