Skip to main content

How to do black-box testing for AJAX Applications?

Posted by inder on October 11, 2006 at 4:50 PM PDT

Web developers are rushing to use AJAX in their Web applications to enhance user-experience. However, testing is a pre-requisite for creating production-quality applications. In this blog, I discuss my attempts on writing automated blackbox tests for the popular Web 2.0 petstore application.

I started out looking for a JUnit based solution. This is because we use NetBeans for developing the petstore application, and it is a breeze to write JUnit tests with NetBeans. Selenium seems quite promising, but it requires that a person runs it in a browser. That requirement makes it unsuitable for ant-based testing that can be done in an automated manner. I am also interested in using JavaScript Unit Tests, and JSUnit. However, those primarily test client-side JavaScript without invoking any of the server-side calls. It is also necessary to simulate how a user will interact with the application by writing a black-box test that mimics a Web client. For this, I chose a JUnit extension, HttpUnit. HttpUnit provides extensive support for making Web requests, parsing HTML, navigating links or clicking buttons. HttpUnit also have basic support for JavaScript but it could not handle dojo, and promptly failed on the very first call.

For now, I am disabling the testing of any of the AJAX calls, but limiting myself to walking through all the pages of the application, and invoking Non-AJAX methods. This is better than no testing, but obviously leaves most of the AJAX invocations untested. Not a good solution.

What do you use for black-box testing of your AJAX applications? Have you written an automated test suite using JUnit? Share your experiences as comments to this blog. Thanks for reading.

Related Topics >>