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

Example: testcases_categories.py. Each module stores several test cases, all related to the common functionality area.

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.

For ease of maintenance and updating of the test suite, the majority of test variables, interface elements and test data are isolated into a separate module testvars.py and organized as global variables, lists and data dictionaries.

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.

Selenium / Python do have some methods for logging test results, but do not have a built-in test reporting tool, so we are using a free third-party procedure, which saves test results to a convenient report in HTML format - HTMLTestRunner (http://tungwaiyip.info/software/HTMLTestRunner.html).
* Special thanks to maggie_s for spearheading the Miro Community test automation with selenium-rc.