【问题标题】:How to run tests from multiple folders in python-behave?如何在 python-behave 中从多个文件夹运行测试?
【发布时间】:2020-12-20 20:09:39
【问题描述】:

有没有办法通过单个 behave 调用从多个文件夹运行测试。

下面是详细的问题。我有两个名为 sample1 和 sample2 的功能文件夹。我想通过单个行为调用在每个文件夹中运行测试。我在配置文件中看到了[paths option](https://behave.readthedocs.io/en/latest/behave.html?highlight=paths#configuration-files),但没有太多可用的文档。是否可以加载特定于每个目录的多个步骤文件?

└── testsuites
    ├── sample1
    │   ├── cpcode.feature
    │   └── steps
    │       └── cpcode.py
    └── sample2
        ├── cpcode.feature
        └── steps
            └── cpcode.py

我已将behave.ini 配置为paths=./testsuites/sample1 ./testsuites/sample2。但是测试结果表明,即使对于sample2文件夹中的Scenario,也选择了sample1中的步骤。

【问题讨论】:

  • 你打算如何运行它?从命令行,从任何 IDE 或其他东西?
  • 我希望从 Jenkins 实例/shell 执行此操作。

标签: python python-behave


【解决方案1】:

其实behaviour.ini里的paths参数就是设置默认值。而且你应该在这里只设置一个文件夹。

[行为]

paths=sample1/.

(确保您在该文件中添加了 [behave])

所以当你需要运行某个功能时,只需运行命令:

behave -k cpcode_sample1.feature

或者您可以显式添加文件夹:

behave -k sample1/cpcode_sample1.feature

behave -k sample2/cpcode_sample2.feature

希望对你有帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-09
    • 2018-12-28
    相关资源
    最近更新 更多