There are two kinds of tests used in Merengue:
Unit tests are executed using the manage.py Django utility located inside every Merengue project, like this:
$ python manage.py testmerengue
This will try to execute all tests in every application defined in the APPS_TO_TEST setting.
You can also launch the test for only one application by appending the application to the end of the command line, as follows:
$ python manage.py test perms
Selenium tests are very useful because they test all application layers (from the database to the user interface). It comes with an IDE to launch and record functional tests:
These are the steps for installing and executing the Merengue Selenium tests suites:
There is a script to execute all suites of selenium tests located in the merengueproj/tests/selenium/generic subdirectories. This script is called run_suites.py and is used as follows:
$ python run_suites.py basic_url
basic_url is the basic url of the domain to test (i.e. http://localhost:8000/). All relative URL's depend on this URL.
It is necessary to run the script with the selenium-server.jar files on the same directory or to give the full path to it with the option --selenium-server.
To avoid launching all the browser windows when testing in your machine and also to allow to run tests in a server it is possible to use framebuffer. Framebuffer allows the allocation of headless displays. To install it run:
$ sudo apt-get install xvfb
and then, to launch it:
$ sudo Xvfb :NUMBER
Finally run the test suite with a non-default display number with the option --display NUMBER.
Note
selenium-server.jar is a file included in Selenium application.
Note for Non-English Browsers
If your browser is configured to use a language other than English, Merengue will use that language by default and the tests will fail. You can create a english firefox profile in a directory and execute the run_suites.py script with the -f option:
$ python run_suite.py http://localhost:8000/ -f ~/.mozilla/firefox/selenium
Also, if you don't want to use other profile, a quick workaround is to disable the 'django.middleware.locale.LocaleMiddleware' from your project middlewares. The setting PRE_MERENGUE_MIDDLEWARE_CLASSES is found in the merengue/settings.py file.
Jul 01, 2011