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: « 147 48 49 50 51 52 53 54 55 56 [57] Show All

2801. clomid for men - 16th Jan 2017 - 3:54 am

http://clomid-for-men.us/#3140 clomid,

2802. trazodone - 16th Jan 2017 - 5:05 am

http://buy-trazodone.red/#3992 trazodone,

2803. metformin - 16th Jan 2017 - 5:23 am

http://metformin.club/#8217 site,,

2804. diclofenac cream - 16th Jan 2017 - 5:41 am

http://diclofenacsodium75mg.click/#1716 diclofenac,

2805. fluoxetine10mg - 16th Jan 2017 - 6:07 am

http://fluoxetine.stream/#9524 fluoxetine,

2806. buspar - 16th Jan 2017 - 7:44 am

http://buspar.kim/#9113 buspar,

2807. augmentin xr 1000 mg - 16th Jan 2017 - 7:53 am

http://buyaugmentin.us.com/#6342 generic augmentin,

2808. celebrex online prescription - 16th Jan 2017 - 8:20 am

http://celebrex365.us.com/#4921 Celebrex,

2809. purchase tretinoin - 16th Jan 2017 - 8:39 am

http://tretinoin-gel.party/#2723 tretinoin cream,

2810. clonidine 0.1 mg tablets - 16th Jan 2017 - 8:56 am

http://clonidine-online.science/#4893 clonidine for tics,

2811. furosemide 20 mg - 16th Jan 2017 - 9:06 am

http://furosemide-20-mg.us/#6836 furosemide,

2812. tadalafil 20mg - 16th Jan 2017 - 9:34 am

http://tadalafil20mg.date/#7855 tadalafil 10 mg,

2813. abilify - 16th Jan 2017 - 9:53 am

http://abilify-online.trade/#1566 abilify,

Pages:« 147 48 49 50 51 52 53 54 55 56 [57] Show All

Leave a comment

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