Tuesday, February 14th, 2006
AJAX and Unit Testing – it’s time to mingle

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).












I wish there was a functional test framework for ajax applications. I know that selenium and watir are evolving in that direction, providing recorders.
Functional tests are very easy to record and playback, if they are a part of the build procedure they can be done faster and ofer better coverage than unit tests.
As written here, developers should only be allowed to interact with the applications they build either in Record mode or Playback mode
Cheers,
Tiago
Of course, what I really meant was http://softwareaddiction.blogspot.com/2005/08/functional-test-first.html
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
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.
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….
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.
There is also SWExplorerAutomation (SWEA) from http://webiussoft.com . SWEA records, replays and generates C# or VB.NET test script code for AJAX applications.