AJAX/javascript testing frameworks and grails

5 views
Skip to first unread message

Ted Naleid

unread,
May 9, 2008, 5:58:42 PM5/9/08
to groo...@googlegroups.com
It's been a while since I've done any heavy ajax/html development and I'm a little out of touch with current best practices around testing and agile development in this area.

How are you guys testing your view code and the code that gets executed on the browser?  Mostly just functional testing of the rendered HTML thorough stuff like canoo and selenium?  Are you doing any TDD or automated unit testing on the javascript that you're creating?

I've seen things like JsUnit (http://blogs.pathf.com/agileajax/2006/06/jsunit_agile_aj.html) and JsMock (http://jsmock.sourceforge.net/) which look interesting.  It also looks like the GWT toolkit also lets you use JUnit (http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.JUnitIntegration.html).

I'm also leaning towards using the jQuery (http://jquery.com/) library as I really like the syntax, the powerful selectors, extensive plugin architecture and the active user community.  It actually feels very close to working with a lot of the groovy code that I've been doing recently, but I'm curious if others have alternate experience that would make them recommend one of the others (GWT, YUI, MooTools, Dojo, the built in Prototype, etc).  I've used prototype/scriptaculous some as well as a little GWT, but don't have much experience with any of the others (and there are _so many_ to choose from these days).

Thanks,
Ted

Mike Hugo

unread,
May 12, 2008, 8:47:52 AM5/12/08
to groo...@googlegroups.com
Hi Ted,

I've been using Selenium for front end functional testing.  There's a selenium plugin for Grails (http://docs.codehaus.org/display/GRAILS/Selenium+plugin) that simplifies setting up test suites, gives you a few handy scripts, and allows you to write tests in GSP instead of HTML if you so desire.  It may take a little bit longer to run than a pure "unit" test framework might, but I like that I can watch the playback and easily determine what went wrong.  I also like that I can use the Selenium IDE (http://selenium-ide.openqa.org/) to run a test in Firefox (provided the test is written in HTML).

Running a whole suite of Selenium tests with Grails while in Development mode can take a while, so I usually will just execute one or two tests (of the piece I'm currently working on) with Selenium IDE, then do 'grails test run-app' and run the suite of tests with the auto-reloading stuff turned off.  I'm also keeping an eye on Selenium Grid http://selenium-grid.openqa.org/ but haven't had a need yet.

As far as JS Frameworks, I have used the built in Prototype/Scriptaculous libraries, with a little help from YUI on occasion (For the Rich-UI plugin and also for CSS reset).  Can't speak to any of the other frameworks though since I don't have any experience with them.

Good luck!

Mike

Ted Naleid

unread,
May 12, 2008, 11:21:37 AM5/12/08
to groo...@googlegroups.com
Awesome, thanks for the tips Mike.  I've been excited about getting to leverage Selenium, it's advanced quite a bit since the last time I used it.

Selenium Grid looks very interesting as well, I'll look into that further for sure.

One of the things I really like about jQuery is that it encourages and makes it easy for you to find and manipulate different pieces of HTML.  It feels a lot cleaner to me to not have to have classes in your html that are specifying a particular style (ex <button class="left orange">...), and using jQuery to find the types of things that (currently) should be "left orange" and adding those styles programatically. I know you can do this with the other AJAX frameworks, but it feels a little more core to the functionality of jQuery and it makes it very easy.

-Ted

Colin Harrington

unread,
May 28, 2008, 9:17:43 AM5/28/08
to groo...@googlegroups.com
Has anyone worked with QUnit or its predecessor? (http://docs.jquery.com/QUnit)
not to be confused with (http://www.coletrain.org/qunit/) or (http://qunit.sourceforge.net/)

~ Colin Harrington

Ted Naleid

unread,
May 28, 2008, 11:19:46 AM5/28/08
to groo...@googlegroups.com
Looks interesting, thanks Colin.  If I move forward with jQuery I'll look into this further for sure.

-Ted
Reply all
Reply to author
Forward
0 new messages