Recipe 20.15. Applying a Unit Test to a Web Page20.15.1. ProblemYour application 20.15.2. SolutionWrite a series of unit tests around Create a file to test something about your web site, example.com. In a file called exampledotcom_tests.php, put: class TestOfExampledotcom extends WebTestCase require_once 'simpletest/web_tester.php'; 20.15.3. DiscussionIf you're dealing with a site that's driven in whole or in part by procedural PHP code, it is sometimes difficult to write a smaller unit test that tests encapsulated functionality. Instead, you just want to make sure that the web site is working; if it isn't, you'll debug from there. Web-page unit testing is a handy technique that is useful whether or not your code base is easily broken into unit tests or not. After all, the real world environment doesn't always behave in the same way as your testing environment, so it can be beneficial to set up a cron job to run a Web Test suite. The SimpleTest WebTestCase supports testing navigation, content, cookies, and form handling. It can even select frames within framesets to conduct tests within a particular frame. If your site makes extensive use of 20.15.4. See AlsoDocumentation on SimpleTest at http://www.lastcraft.com/simple_test.php; the Selenium project page at http://www.openqa.org/selenium/. |
Thursday, February 4, 2010
Recipe 20.15. Applying a Unit Test to a Web Page
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment