Tuesday, February 14th, 2006

AJAX and Unit Testing – it’s time to mingle

Category: Ajax, JavaScript, Testing

Jim Plush has a new post over on his blog today suggesting the “mingling” of two things that can help to make more powerful, robust web applications – Ajax and Unit testing.

I’ve decided to write a little two part introduction into unit testing your AJAX applications with JSUnit. AJAX applications now are adding a new complexity into our development lives. Introducing business logic into our presentation tier. It is now not enough to write some adhoc javascript form validation functions that work most of the time. You now need to take accountability for your javascript code as it can affect your business logic on the server side.

He uses the JSUnit testing library for his examples, describing how to install and use it in your scripts to test. He provides an image of the testing setup he’ll use and guides you through a setup for the testing environment. With the filesystem structure in place, you can create the sample “TestRunner” script to ensure that everything’s set up correctly (and familiarize yourself with the interface).

Posted by Chris Cornutt at 8:14 am

3.6 rating from 22 votes


Comments feed TrackBack URI

AJAX has indeed shaken up the testing tools scene. I created Selenium in 2004 when I found the existing tools (including JSUnit) couldn’t test the AJAXy things I was doing in the browser back then. Selenium is now one of the few tools (for any price) that can functional test an application from end to end – login to logout in IE and Firefox on Windows, Linux, and Mac. JSUnit is really only designed to handle the testing of code in one page… when you need to handle transitions from page to page, then you need something like Selenium.

Watir is similar to Selenium, but is tied to IE (for now), Windows and Ruby only. However, whatever Watir lacks in scope (OS, browsers, and language support) it more than makes up for it in technical depth in terms of all the cool things you can do with Ruby scripting the IE browser.

-Jason Huggins

Comment by Jason Huggins — February 15, 2006

You can try SWExplorerAutomation (www.webunittesting.com)
The program creates an automation API for any Web application which uses HTML and DHTML and works with Microsoft Internet Explorer. The Web application becomes programmatically accessible from any .NET language.
SWEA API provides access to Web application controls and content. The API is generated using SWEA Visual Designer. SWEA Visual Designer helps create programmable objects from Web page content.

Comment by Alex — March 27, 2006

Looks like there is new framework for testing Ajax applications in .net. Check out http://www.artoftest.com. I like their new TestRegion approach to abstract out segments of your app….

Comment by John Smic — January 24, 2007

InCisif.net is an automation tool designed to implement client-side functional testing of web applications under Internet Explorer 6.x or 7.x, using the C# or VB.NET language with Visual Studio 2003, 2005 or Visual Studio Express Edition 2005.

Check out our blog blog.incisif.net for new methods to support AJAX applications.

Comment by Frederic Torres — January 27, 2007

Leave a comment

You must be logged in to post a comment.