Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Purdy (2383)

Purdy
  reversethis-{ofni.ydrup} {ta} {nosaj}
http://purdy.info/
AOL IM: EmeraldWarp (Add Buddy, Send Message)
Yahoo! ID: jpurdy2 (Add User, Send Message)

Bleh - not feeling creative right now. You can check me out on PerlMonks [perlmonks.org].

Journal of Purdy (2383)

Friday January 02, 2009
10:29 PM

A new way to test (to me?)

[ #38209 ]

It's a shame all of my code can't reside in the tidy confines of my Perl libraries - from time-to-time, I have to write JavaScript for a better browser experience. If you haven't heard, Yahoo's YUI has a testing framework (YUITest) that is pretty neat and I'm now using it (vs. Selenium).

Granted, I wasn't heavily invested w/ Selenium, so switching wasn't really that much of a hurdle. But YUITest is pretty cool stuff. I will tell you that it's no Test::More. It doesn't have cmp_ok, so you have to program around it a bit. And you have to program in JavaScript, itself.

What I found as a neat approach is to write the self-contained YUITest code in a separate file in a template directory (i.e. selectTest.yuit).

Then in my app code, I pass along a conditional template parameter that will include that .yuit template contents and then tie that to a query parameter ... i.e.

http://www.example.com/myApp.cgi

And that'll run the app as usual. Then if I append ?t=1, then my app will suck in the .yuit file, which brings in the YUITest framework and runs it. You could get more advanced and automate it and use the framework's reporting functionality to make things even more robust.

Peace,

Jason

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I recently wrapped the java HtmlUnit library in Perl (see CPAN) -- it is kinda like WWW::Mechanize except with a fairly functional javascript engine. I don't know if it'll run the YUITest framework, but it might be worth a try. I hope to also wrap the Mechanize API and eventually have Test::WWW::Mechanize::HtmlUnit or similar.