Setting up django-behave

Install django-behave from pypi or github.

Edit test_settings.py (or which settings file you use when running tests). Add this: INSTALLED_APPS += ('django-behave', ) TEST_RUNNER = 'django-behave.runner.DjangoBehave_Runner'

Create a features dir, in the apps you want to test.

If you then run test on that app, you should now see something like this: ` (ve)$ PYTHONPATH=. python proj/manage.py test author –settings=proj.test_settings

E

ERROR: runTest (django-behave.runner.DjangoBehaveTestCase)

Traceback (most recent call last): File “…/ve/lib/python2.7/site-packages/django-behave/runner.py”, line 57, in runTest sys.exit(str(e)) SystemExit: No steps directory in “…/proj/author/features”


Ran 1 test in 0.525s

FAILED (errors=1) Destroying test database for alias ‘default’… `

Add the steps directory. Rerun the test and you’ll be told you don’t have any features.

So now you can start writing tests.

Create an features/environment.py if you want generic setups; see http://packages.python.org/behave/api.html#environment-file-functions

Take a look at django-behave/steps_library.py for some useful steps; you might want to copy that into features/steps/library.py.