I'm currently in the middle of writing a reusable little JavaScript utility, which I'll probably release when it's finished, for one of my many projects and I wanted to employ unit testing as part of the development process, as I believe in the benefits of it quite strongly.

However my previous experience with unit testing JavaScript haven't been the most pleasent, I have tried the most common nUnit variations for JS, the best of which was JSUnit. But I always found this a little cumbersome and difficult to use, however I had recently read about the unit testing available with script.aculo.us and although the only documentation I could find was the PDF available at mir.aculo.us I thought I'd give it a go.

My only worry with using the script.aculo.us unit testing was its dependency on prototype and script.aculo.us (obviously) and now I've moved across to mootools for most things I thought there may be some clashes between prototype and mootools for this.

However with the current versions of each of those I managed to get everything working by changing only two lines in the unittest.js:

  1. Event.observe(td, 'click', function() ...


  1. $( td ).addEvent( 'click', function() ...

The script.aculo.us unit testing framework is very fast (one of my tests performs 16 tests with 1904 assertions in about a second) and it does a great job of catching scripting and syntax errors and presenting those in a useful way without breaking the tests, which some frameworks I've used in different languages don't always handle too well.

The only let down is the current level of documentation, but if you've looked at unit testing in any other language this is almost the same and you can figure out what most of the assertions do from reading the PDF and looking at the source. The only minor niggle is the need to use the

  1. with( this ) {
  2.     ...
  3. }

syntax for all your assertions, I haven't found an explanation for why this is needed within each of the test methods and why it can't be hidden from the user, but you need it otherwise it won't work.

I haven't looked at using the functional tests available within script.aculo.us yet as it's still at a very early stage and I'm not sure whether it's needed as I think I can do everything I need right now with unit tests. I hope to write more about specific examples of unit tests, e.g. complex ones which require DOM manipulation or user interaction etc., in JavaScript when I have some decent examples in place.


There have been 3 comments so far, join the discussion.

Pages: « 117 18 19 20 21 22 23 24 25 26 [27] Show All

1301. abilify on line - 3rd Dec 2016 - 5:53 pm

http://costofabilify.us/#4251 canadian abilify,

1302. view homepage - 3rd Dec 2016 - 6:01 pm

http://mobic-drug.party/#2529 mobic drug,

1303. generic tadalafil 40 mg - 3rd Dec 2016 - 6:46 pm

http://generic-tadalafil.science/#5006 generic tadalafil,

1304. acyclovir 800 mg - 3rd Dec 2016 - 7:04 pm

http://acyclovir-800-mg.science/#5062 acyclovir,

1305. viagra soft - 3rd Dec 2016 - 7:12 pm

http://viagra-soft-online.trade/#2321 viagra soft 100mg,

1306. buy azithromycin - 3rd Dec 2016 - 7:21 pm

http://buyazithromycin.site/#8596 azithromycin,

1307. buy cipro - 3rd Dec 2016 - 7:47 pm

http://buy-cipro.gdn/#8655 buy cipro,

1308. tetracycline - 3rd Dec 2016 - 8:04 pm

http://tetracycline-cost.science/#4048 more,

1309. trazodone 100 mg - 3rd Dec 2016 - 10:01 pm

http://trazodone-100-mg.science/#4712 trazodone,

1310. citalopram - 3rd Dec 2016 - 10:20 pm

http://citalopram-hydrobromide.science/#2895 citalopram hydrobromide,

1311. hydrochlorothiazide - 3rd Dec 2016 - 10:47 pm

http://losartan-hydrochlorothiazide.science/#2653 hydrochlorothiazide 25mg,

1312. viagra - 3rd Dec 2016 - 11:04 pm

http://generic-viagra.cricket/#1471 non generic viagra,

Pages:« 117 18 19 20 21 22 23 24 25 26 [27] Show All

Leave a comment

No HTML please, only textile. For code please use [lang]...[/lang] tags (e.g. [html]...[/html] for HTML)