Search code examples
djangopython-3.xpython-behave

How to execute a scenario from a step in another scenario?


Below is the example I want to execute a scenario in another scenario. How can I do this?
I've already known that I execute the other steps by using execute_steps().

My environment: macOS v10.14.1, Docker v18.06.1-ce, Django v2.1.4, behave v1.2.6, behave-django v1.1.0

Scenario: scenarioA
    Given ~
    When ~
    Then ~

Scenario: scenarioB
    Given scenarioA is completed # I want to exexute scenarioA here.
    When ~
    Then ~

Is there an api to run the scenario from the name of the scenario?
Is there an api that gets scenarios from scenario names and divides them into steps?


Solution

  • No. This behavior is done deliberately, to eliminate collisions in cases where scenarioA falls during a call by scenarioB.

    Behave API has only one method to call another step from current step: execute_steps()

    Official tutorial with exactly example: macro step