Search code examples
pythonpython-behave

Run python behave from python instead of command line


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


Solution

  • Found the solution by working through the behave source code:

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

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