0

I have a set of Behave (1.2.6) features and scenarios that are all working correctly individually. But based on certain initial conditions, I need to run subsets of them in a specific order. I know it's not the right way to do BDD (each test should be independent, with its own setup and teardown), but these are integration tests against an actual deployed web app (no mocking), and the setup and teardown take far too long.

I could drive it from a shell script that runs each test in a separate behave run. But I'd like to have a python driver function that would examine the initial conditions, run the requested set of tests in the right order, and output combined summary stats.

So how can I invoke a Behave scenario from a Python function?

1 Answer 1

2

You can import the main function and run it:

from behave.__main__ import main

main("--tags smoke")
Sign up to request clarification or add additional context in comments.

1 Comment

It would have required too much digging into Behave internals to do what I wanted, so I found a better way within my test logic. But you answered my question as asked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.