Search code examples
pythonbddpython-behave

Select rows from behave table in Python


I am using the behave framework for developing tests in Python. At the moment, I have a scenario outline and examples underneath it. I would like to be able to just select one of these examples at any time and run the test feature on that example. How would I go about doing it? Right now, whenever I invoke behave from the command line it executes the scenario against every example entry in the Examples behave table I have under my Scenario Outline.

EDIT: I have attached a screenshot to make things more clear.

enter image description here

This example is from behave's documentation. If we have a look under the Consumer Electronics table, we see 2 rows, for which the Scenario Outline will run (so it will run twice). Say I would like to test for one of these examples, and we had 20 of these examples (meaning 20 rows). How would I be able to choose just one of them instead of running my behave tests and having to wait for the Scenario Outline to finish all cases (if the example I want is the last entry on the table for example).


Solution

  • The way I had done this was to have multiple 'Examples' tables with different names. Then pass the --name parameter when behave is called.