Monday, March 20

Testing Web Pages

I feel compelled to make a quick shoutout for JWebUnit, a unit testing framework for web pages. Basically, it’s an embedded Java HTTP client that allows you to programmatically access URLs, inspect pages, manipulate forms, and click links.

This is useful because it lets you write tests against web app behavior. So, if you change, say, Blogger, you can run tests to ensure that it’s still possible to post and comment, and that the access control works, and that posts show up right, etc.

I’ve — up until now — mostly scoffed at automated web testing. This is because it really doesn’t address design concerns, and doesn’t do heavy lifting on issues like cross-browser compatibility.

But, I’ve been working a bit on the Blogger comments form, and I have to admit I’m really quite pleased to have the confidence in my changes that passing the automated tests gives. If you’re curious about why this is necessary, play around with your comments settings and access the comments page in various states of logged in and not. Given all the possible combinations, it’s really necessary to ensure that each little permutation works the way it’s supposed to.

So, I’m pretty happy, but one major flaw in JWebUnit is that it doesn’t let you change hidden form fields. While this is authentic in that well-behaved user agents don’t let users change hidden form fields, but I’d much rather have tests to make sure that if a curious or malicious user did start playing around with those, the app would behave reasonably, or at least blow up without letting anyone do anything they shouldn’t.