I can run my behave code with the --format and --outfile parameters, and works as expected.
behave 00-test.feature --format json --outfile "C:/results.json"
Which will give me the results in a json format in C:/results.json.
I want to avoid passing those variables through behave.ini and command line. I want to set those variables in the enviroment.py so I can simply run the following from anywhere:
behave 00-test.feature
Within the environment.py file, I have tried all the combinations I can think of and they all come down to these three variables, but no luck.
def before_all(context):
...
context.config.outfiles = ["C:/results.json"]
context.config.outputs = [StreamOpener("C:/results.json")]
context.config.formatters = ['json']
...
Why StreamOpener? https://github.com/behave/behave/blob/master/behave/configuration.py shows outputs is a list of StreamOpener objects.
Anybody know the proper way of setting the outfiles and formatters in python-behave?
Is this a solution? I run it from another module like this
from behave import __main__ as behave_executable
behave_executable.main(args="--format json --outfile results.json")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With