Run python behave from python instead of command l

2019-04-08 10:25发布

问题:

Is there any way to run python behave from within python and not via command line?

default usage: run behave command in base folder with features/steps

desired usage: call a function (or have a certain import) which executes the behave tests in a specified folder

回答1:

Found the solution by working through the behave source code:

from behave.__main__ import main as behave_main
behave_main("path/to/tutorial")

The main method of behave enumerates and processes all paths it finds in its arguments.