pythonpython-behave

Create a feature, scenario, and its steps at runtime


I'm using python-behave to run some test. For a "proof-of-concept" project I would like to create a test (feature/scenario) at runtime.

I'm gathering the test steps from a web server and try to build a Scenario object. One idea was to use the before_all hook to get the steps from the server and compile them together. But I cannot find an example of how to make a scenario or step object.

get steps as strings from server --> compile/build scenario --> run test/scenario

Does anyone have an example?


Solution

  • Finaly I did it the other way around. I imported the behave main and called it with a file I dynamically write.

    from behave.__main__ import main as behave_main
    ...
    behave_main(['-i', 'myDynamicTest.feature', ...])