OSCON 2006: Rock-solid Web Development: Testing Web Apps

Tweet

All this week, Kevin Yank is reporting from OSCON 2006 in Portland, OR.

Presenter John Paul Ashenfelter provided the standard sales pitch for testing, but with a web development spin, and demonstrated both Selenium (a rich, in-browser testing framework that lets you write and run your tests using nothing more difficult than HTML and CSS) and The Grinder (a free load testing tool that can be cumbersome to use, but won’t cost you an arm and a leg). The slides and supporting materials from the tutorial are available on the TransitionPoint web site.

Testing is a discipline in itself, with sub-disciplines like user testing, functional testing, and load testing. The desktop web development world—and to some extent, the enteprise web development world—is adopting all these types of testing at an impressive rate, but some of the unique challenges faced by web developers (e.g. multiple browsers) mean that testing is taking hold more slowly in that world. In this talk, Ashenfelter demonstrated the state of the art of testing in each of these sub-disciplines, where the tools involved range from the daunting to the inspiring.

If you haven’t seen Selenium in action, you owe it to yourself as a web developer to at least download Selenium Core, extract it, open the index.html file, and run the built-in set of tests in Selenium TestRunner. Watch your browser (no matter which browser you use) immediately become a testing framework as it automatically interacts with a series of pages and verifies that they behave as they should.

If you’re impressed, try your hand at writing a few tests yourself (hint: all you need to write is an HTML table), or take a look at Selenium IDE, a Firefox extension that can record user actions and generate a testing script on-the-fly.

Less straightfoward is The Grinder, a free load testing tool written in Java, which is Ashenfelter’s tool of choice not because it is especially easy to use, but because it’s the only one that won’t cost you tens of thousands of dollars to use in the real world. The fact that it’s open source is just a bonus in this case.

The Grinder works by recording your interactions with a site by configuring your browser to connect to the site through a proxy server. Those interactions produce a Jython (Python on Java) script that you can then tweak by hand. Once you’ve got a script, you can set up The Grinder to pommel your site with tens (or thousands) of instances of that script being executed at once.

Ashenfelter admitted that load testing is not an easy problem to
solve. He even suggested that if your testing target is nontrivial, you might
just be better served paying a consulting firm to come in and do it for
you. But for the do-it-yourselfers, The Grinder is a capable (if cumbersome) tool.

Tying all your testing efforts together and getting your fellow developers to use the testing tools and pay attention to the results requires a little work as well, and Ashenfelter’s advice here was to use the standard tools like CruiseControl, and to set up “Information Radiators”—systems for developers to receive the results of automated testing in low-noise, high-profile ways that won’t get ignored (as, say, a daily email will).

Free book: Jump Start HTML5 Basics

Grab a free copy of one our latest ebooks! Packed with hints and tips on HTML5's most powerful new features.

  • nicklo

    You may be interested in the Firefox extension “TestGen4Web”. It’s “a tool which can record user actions on firefox. Save the recording to an xml file, also replay the saved recording. The output of the recorder can also be translated into automatic testing scripts such as httpunit, selenium, simple-test etc.”

    http://developer.spikesource.com/wiki/index.php/Projects:TestGen4Web

  • http://www.sitepoint.com/ Kevin Yank

    Nicklo,

    How is that different from what Selenium IDE can do? Or is it just the fact that the recorded scripts can be used in multiple frameworks?

  • nicklo

    Hi Kevin,

    Well I wasn’t suggesting it was necessarily different. Perhaps I should have said “Your readers may ALSO be interested in…”. To be honest I’ve not really used it much but reading your post reminded me of it and that maybe I should put it to more use.

  • malikyte

    Anyone able to compare The Grinder to Apache JMeter and direct variations thereof? Also, considering the many different open source options for load testing, and his honesty about Grinder’s difficulty, I have to wonder if perhaps there would be a better alternative.

  • http://www.sitepoint.com/ Kevin Yank

    malikyte,

    The Grinder actually relies on JMeter internally, so if JMeter does all you need then it will certainly be a simpler tool to use. The Grinder builds on top of that simple foundation a framework for recording user interaction scripts and playing them back from multiple agents distributed across your testing network, and monitoring the results from a single console.