Configuration

Command line options

You can use regular behave command line options with the behave management command.

$ python manage.py behave --tags @wip

Additional command line options provided by behave-django:

--keepdb

Starting with Django 1.8, the --keepdb flag was added to manage.py test to facilitate faster testing by using the existing database instead of recreating it each time you run the test. This flag enables manage.py behave --keepdb to take advantage of that feature. More information about --keepdb.

--runner

Full Python dotted path to the Django test runner module used for your BDD test suite. Default: behave_django.runner:BehaviorDrivenTestRunner

You can use this option if you require custom behavior that deviates from Django’s default test runner and is hard or impossible to configure.

Note

Not to be confused with --behave-runner that handles the internal test runner inside behave. You would use that to override behave’s feature/step file discovery and similar behavior. Read more about it in the behave docs.

--simple

Use Django’s simple TestCase which rolls back the database transaction after each scenario instead of flushing the entire database. Tests run much quicker, however HTTP server is not started and therefore web browser automation is not available.

--use-existing-database

Don’t create a test database, and use the database of your default runserver instead. USE AT YOUR OWN RISK! Only use this option for testing against a copy of your production database or other valuable data. Your tests may destroy your data irrecoverably.

Behave configuration file

You can use behave’s configuration file. Just create a behave.ini, .behaverc, setup.cfg or tox.ini file in your project’s root directory and behave will pick it up. You can read more about it in the behave docs.

For example, if you want to have your features directory somewhere else. In your .behaverc file, you can put

[behave]
paths=my_project/apps/accounts/features/
      my_project/apps/polls/features/

Behave should now look for your features in those folders.