[英]Using Behave to run a series of feature files
I have a series of embedded applications that I use Behave to test, so I have several folders with feature files and step implementations.我有一系列使用 Behave 来测试的嵌入式应用程序,因此我有几个文件夹,其中包含功能文件和步骤实现。 So to test each application, I go into each one of the application folders and run Behave.
因此,为了测试每个应用程序,我将 go 放入每个应用程序文件夹并运行 Behave。
I was thinking about how can I create a top-level test file that I could run to test all applications.我在考虑如何创建一个可以运行以测试所有应用程序的顶级测试文件。
I know Gherkin doesn't allow importing a feature file into another feature file, so I can't have a top-level file that imports the other feature files.我知道 Gherkin 不允许将功能文件导入另一个功能文件,所以我不能有一个顶级文件来导入其他功能文件。
I think the obvious answer would be to move the individual feature files for each test to as scenarios in a top-level feature file and control what is tested with tags.我认为显而易见的答案是将每个测试的单个功能文件移动到顶级功能文件中的场景并控制使用标签测试的内容。 That would be doable, with is a lot of re-work and I'd rather not deal with all the possible interactions between the different scenarios.
这将是可行的,但需要大量返工,我宁愿不处理不同场景之间所有可能的交互。
And what if I created this top-level test as a separate Behave test that would go into each individual folder and run Behave?如果我将这个顶级测试创建为单独的 Behave 测试,将 go 放入每个单独的文件夹并运行 Behave,该怎么办? Let's say that I have the following folder structure:
假设我有以下文件夹结构:
samples/
│
└tests/
│
├── BehaveTest1
│ ├── BehaveTest1.feature
│ └── steps
│ └── test_steps.py
└── BehaveTest2
├── BehaveTest2.feature
└── steps
└── test_steps.py
I know I can run Behave in both folders with我知道我可以在两个文件夹中运行 Behave
behave samples/tests/BehaveTest*
How can I use Behave to automate that?我怎样才能使用 Behave 来自动化呢?
In the samples
folder I'd have the following feature file:在
samples
文件夹中,我将具有以下功能文件:
Feature: Test everything
Scenario Outline: Test all samples
Given the test folder is"<test_folder>"
When we run the test
Then the test is successful
Examples:
| test_folder |
| BehaveTest1 |
| BehaveTest2 |
The step implementation would change to the correct folder and load the feature file.步骤实现将更改为正确的文件夹并加载功能文件。
How can I do this with Behave?我如何使用 Behave 做到这一点?
Many thanks!非常感谢!
why don't you use tags?你为什么不使用标签? tags can be used on feature and scenario level
标签可用于功能和场景级别
features特征
i believe you have this kind of nested structure.我相信你有这种嵌套结构。 you can run it any feature file based on ur tag
您可以根据您的标签运行任何功能文件
behave --tags @smoke and if you want to ran them parallel not sequential then try out Behavex, thats another layer on top of behave.
表现 --tags @smoke 如果你想并行运行它们而不是顺序运行,那么试试 Behavex,这是在表现之上的另一层。 behavex -t @tag1,@tag2 --log-capture --parallel-processes 3 --parallel-scheme feature -o Reports
行为x -t @tag1,@tag2 --log-capture --parallel-processes 3 --parallel-scheme feature -o Reports
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.