Archive for the ‘jsunit’ Category

running JsUnit tests in the Eclipse browser preview tab.

July 12, 2007

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)

Advertisements

Excellent article on Firebug debugging.

July 11, 2007

Firebug is the Dog’s Bollocks, In fact I’m finding the trinity of Firebug , Aptana and JSunit a truly fantastic setup for developing robust browser based applications. I just read Justin Palmer’s tutorial on the logging capabilities of Firebug. Really good info, well presented. excellent signal to noise ratio.

Although I already knew most of the stuff covered, as I had been a beta tester of Firebug 0.4, I had missed the trace() function and the fact that the standard log() functions support jQuery/Prototype $functions so you can use the following incredibly useful pattern to inspect the html of the object you are manipulating.

console.log($('#item_id'))

Read the article and write better code.