我可以使用 --format 和 --outfile 参数运行我的行为代码,并按预期工作。
behave 00-test.feature --format json --outfile "C:/results.json"
这将为我提供 C:/results.json 中 json 格式的结果。
我想避免通过 behavior.ini 和命令行传递这些变量。我想在 enviroment.py 中设置这些变量,这样我就可以从任何地方简单地运行以下命令:
behave 00-test.feature
在 environment.py 文件中,我尝试了所有我能想到的组合,它们都归结为这三个变量,但没有运气。
def before_all(context):
...
context.config.outfiles = ["C:/results.json"]
context.config.outputs = [StreamOpener("C:/results.json")]
context.config.formatters = ['json']
...
为什么选择 StreamOpener?https://github.com/behave/behave/blob/master/behave/configuration.py 显示输出是 StreamOpener 对象的列表。
有人知道在 python-behave 中设置输出文件和格式化程序的正确方法吗?