In behave, how do you run a scenario only?

If you want to run a single test for that feature, use the -n or --name flag which seems to want the text after Scenario:

behave -n 'This is a scenario name'

You can run a feature file by using -i or --include flags and then the name of the feature file.

behave -i file_name.feature

or:

behave --include file_name

You can also exclude with the --exclude flag:

behave -e file_name

For more information check the documentation for command line arguments. There’s a lot of useful information hidden in their appendix section.


NOTE: At the time I’m writing this it won’t work with Python 3.6 and Behave 1.2.5, due to this issue. (UPDATE: 1.2.6 is out and fixes this, but if you’re on python 3.4 that version won’t be available from pip so you can workaround this with pip3 install git+https://github.com/behave/behave#1.2.6rc).

It also seems like you should be able to pass in the text after Feature: for the -i flag but currently that doesn’t work. Somebody remind me to updated if it works again. I also encourage people to check out the wip flag, which allows you to add @wip to a test, then -wip will not only run the test but also allow print/logging statements for debugging.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)