Django Integration

admc edited this page Sep 13, 2010 · 1 revision

Executing tests from Django’s test System

It is possible to execute windmill tests from the django test system.

Since the django test system uses unittest and doesn’t have a lot of debugging facilities you should still develop and debug tests normally in windmill. This support is only intended to allow you to execute windmill tests against your django app along side your other django unittests.

Example:

import os
from windmill.authoring import djangotest 

class TestProjectWindmillTest(djangotest.WindmillDjangoUnitTest): 
    test_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'windmilltests')
    browser = 'firefox'

Adding this test class anywhere that django’s unittest system looks for tests will bootstrap the windmill test system for a directory of windmill Python tests.

Windmill’s django support dynamically modifies some of the django test system to add live test server support. The WindmillDjangoUnitTest? class will start up the test server and launch which ever “browser” you set in the unittest class. All the hard parts are handled for you.

The only major downside of this support is that the entire windmill test run looks like one single test to django’s unittest framework. If you want to know how many windmill tests failed and why all you’ll see from the django unittest system is a single failure for this test case. Therefor debugging windmill tests will require you running them with windmill outside of the django unittest system.

Using manage.py test_windmill

As of r1172 part of Windmill 1.1 release, windmill includes a django custom management command.

To enable this custom management command add “windmill” to your list of INSTALLED_APPS in your django project.

Unlike the support above, this command just starts your django test server and kicks off functest execution of your tests. If you have defined windmill tests using the method above they will be discovered. It will also discover any Python modules in your installed applications (listed in settings.py) named wmtests or windmilltests.

python manage.py test_windmill

By default windmill will run the tests in Firefox but can you can pass all the other supported browsers to override this.

python manage.py test_windmill safari