Chapter 7. Testing Web Sites

Are you designing a web site and creating tests before or during its construction? Do you already have a site and want to prove that it works? A variety of design choices can help you make more robust web-based applications, from isolating the logic behind the pages to ensuring what happens when a user clicks the Submit button. The CPAN provides several modules that allow you to create useful tests for your web applications.

This chapter demonstrates how to build web applications with testing in mind as well as how to test them when you deploy them. The labs show how to record your interaction with these programs and how to validate HTML in a few different ways. Finally, the chapter walks through setting up an instance of the Apache web server specifically designed to make testing Apache modules easy.

Testing Your Backend

A friend of one of the authors has frequent table tennis tournaments at his workplace and has long considered building a web application to keep track of player rankings. The application, Scorekeeper, should maintain a list of games, who played in each game, the final scores for each game, and when the game took place. The application also should show how well players perform against others overall—mostly for heckling purposes.

The conceptual relationships are immediately apparent: a game has two scores and each score has a player and a game. It’s easy to model this with a relational database. The next step is to build the GUI, right?

Get Perl Testing: A Developer's Notebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.