Monday, October 20, 2008

First Resort Approaches to Testing a Web Application

Testing a web application is not simply a task of making large selenium integration tests. In fact, this should be the last thing that you do after getting all of the individual pieces tested. There are many pieces that go together with completing a test effort for the app. Creating a variety of small tests can make life a lot easier and can expose bugs during development, early in the life cycle of feature development.

The following are some areas that you don't want to miss when testing your application:

One of the first things to do is unit test your Java code. This is easy for the developers of the features to do as they write methods and classes and check them in. Unit tests should be set up in a continuous build to expose bugs quickly.

Today's web apps include a lot of javascript for dynamic features, and sometimes these pieces can comprise a lot of the code that contributes to the feature set of an application. So, the second most important part of your testing package is to develop JS unit tests for all the classes and method delivered to the browser.

How do you run these tests. Selenium can be easily used to load javascript tests and run them. The key holes into the the javascript here are the getEval function and the runScript function. In fact, one could develop an entire framework for running JS tests automatically. Still, using Selenium requires opening up a browser, which takes a relatively long time. An interesting idea here would be to to develop a service that could extract the javascript interpreter from the rendering engine. You could send javascript the service with you JS unit tests to adequately test all your javascript.

The final page rendering is also quite important, because this is what the user sees and what he interacts with. It's a true test of the user experience. Having a set of pages that a heavy user of the web application might expect to see should be the goal here. You can do all of the set up work for these pages using API's or the javascript service and then you can use Selenium to navigate to the expected resulting page. Selenium can be used to test elements on that page, or an image comparison tool can also be used to test that the page looks as expected to the user.

Finally, the old fashioned way of Selenium is necessary for a complete integration and sanity check of the entire system. Basic functionality should be tested to ensure quality. Remember that limiting the number of large tests for a web application is important for reducing maintenance costs, and for ensuring that the most important pieces of the app are tested.

No comments: