[Zope-Coders] Website regression testing tool now available

Richard Jones rjones@ekit-inc.com
Wed, 27 Feb 2002 12:15:24 +1100


While at Bizar Software, I developed a tool for unit/regression testing 
websites. The kind people there have open-sourced the tool, and I've since 
extended it and am now using it at ekit.com.

I say unit/regression because it uses the python lib unittest framework for 
the actually running of the tests, but the tests are almost always written 
after the fact :) There's no reason why the tests couldn't be written 
beforehand though.

The code is available at:

   http://mechanicalcat.net/tech/webunit/

with some basic documentation at:

   http://mechanicalcat.net/tech/webunit/README.html

A sample test class::

class TestGoogle(WebTestCase):
    def setUp(self):
        self.server = 'www.google.com'

    def test_home(self):
        page = self.page('/')

    def test_form_good(self):
        page = self.page('/')
        page = page.getForm(0, self.page, {'q': 'Python Rules',
           'btnG': 'Google Search'})

    def test_form_bad(self):
        page = self.page('/')
        page = page.getForm(0, self.assertContent,
            {'q': 'eereerererre', 'btnG': 'Google Search'},
            'did not match any documents')


      Richard