test suite organization model for Miro Community
Structure of a test suite for Miro Community
test_withHTMLoutput.py is the main module of the suite. It defines the class Test_HTMLTestRunner with the test Test_HTMLTestRunner.test_main, which forms a Selenium test suite from a number of test cases testcases_<functional_area>.TestCase_<test_case_name>.
The test cases are defined in their respective modules, which are named testcases_<functional_area>.py
A test case is described as a unittest class with three mandatory and, possibly, a few optional procedures. The mandatory procedures are:
setUp - defines the environment and starts the browser session
test_<test_name> - the body of the test, simulating user actions
tearDown - closes the browser, performs memory cleanup and checks for verification errors
Note that for Miro Community, each test case starts in an individual browser window and begins with logging in to the test dev site. (This step cannot be omitted, since Selenium RC runs browser sessions with a local proxy and MC server does not recognize the previously logged in virtual user in each new browser session.)
Once the virtual user has logged in, one or more procedures are called from the test body procedure. Each procedure corresponds to a particular task (e.g. add a user or change the site theme) and describes the sequence of user actions needed to accomplish this task. These procedures are stored in external modules named <functional_area>.py (example: categories.py).
A few general purpose procedures and functions, such as removing HTML tags from a text string, are stored in a separate module mclib.py.
Test results are logged through testcase.verificationErrors.append method (errors) and print method (errors and all diagnostic and debugging messages). After the test run is complete, Test_HTMLTestRunner.test_main saves test results to a timestamped HTML test result file.