简体   繁体   English

使用 Behave 运行一系列特征文件

[英]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特征

  • folder1文件夹1
    • steps脚步
      • your_step_file your_step_file
    • test1.feature (feature level tag "regression") test1.feature(特征级别标签“回归”)
    • test2.feature (feature level tag "smoke") test2.feature(功能级别标签“烟雾”)
  • folder2文件夹2
    • steps脚步
      • your step file你的步骤文件
    • test1.feature (feature level tag "regression") test1.feature(特征级别标签“回归”)
    • test2.feature (feature level tag "smoke") test2.feature(功能级别标签“烟雾”)

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.

相关问题 无法在 Spyder 上使用行为运行功能文件 - Unable to run feature files using behave on Spyder 如何使用pycharm professional运行多个功能文件 - How to run multiple feature file in behave using pycharm professional 通过行为仅运行功能/步骤文件 - Running only Feature/Steps files with Behave 正在运行的功能文件python行为-Pyhcharm-未找到功能 - Running feature files python behave - Pyhcharm - No Feature found 使用多个用户数据可能性运行 my.feature 文件 - run my .feature files using multiple userdata possibilities 使用scons来运行perl脚本(该脚本会自动生成一系列文件),然后编译这些文件并创建一个静态库 - using scons to run a perl script (which autogenerates a series of files) then compile these files and create a static library Python 行为特征文件警告 - Python Behave feature file warnings 打开一系列终端并运行bash文件 - Open a series of terminal and run bash files 如何使用 Python 中的行为命令执行 1 个特定功能文件? - How do I execute 1 specific feature file using behave command in Python? 为什么 Pandas 系列切片在使用索引号和索引值进行切片时表现不同? - Why does Pandas Series slicing behave differently when slicing using index numbers versus index values?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM