gpt4 book ai didi

python - 使用行为标签仅执行此类标签的子案例

转载 作者:太空宇宙 更新时间:2023-11-03 14:59:57 26 4
gpt4 key购买 nike

我在 sample.feature 文件中有以下场景定义,其中场景使用 Examples 语法包含两个子案例:

  @ninja
Scenario Outline: this is a sample scenario
Given ...
And ...
And ..
When ...
Then ...

Examples:
| param1 | param2 | param3 |
| 10 | 4 | 9 |
| 20 | 8 | 23 |

我可以使用标签 ninja 仅执行该场景以及 sample.feature 文件中定义的所有其他场景,如下所示:

$ behave sample.feature --tags=ninja
...
Scenario Outline: this is a sample scenario -- @1.1
...
Scenario Outline: this is a sample scenario -- @1.2
...

请注意,行为“标记”每个子案例执行,即执行日志中的 @1.1@1.2

我想知道我是否可以更加“敏锐”,并使用behave仅执行给定标签的一个(或子集)子案例。我尝试了以下操作,但没有成功(即两个子情况都执行,而不仅仅是第二个):

$ behave sample.feature --tags=ninja,1.2

这可能吗?请问有什么方法可以帮忙吗?

最佳答案

是的,可以只执行场景大纲中的一行(示例),首先需要在功能文件中的标记中定义占位符,例如:
@test.row<row.id> Reference in Behave

之后执行:

behave example.feature -t @test.row1.2 -- run only the row: 2 with this tag.

也可以创建几个示例,如下所示:

    Examples:
| param1 | param2 | param3 |
| 10 | 4 | 9 |
| 20 | 8 | 23 |
Examples:
| param1 | param2 | param3 |
| 30 | 12 | 1 |
| 40 | 13 | 45 |
| 50 | 14 | 49 |
| 60 | 15 | 13 |

并且,

behave example.feature -t @test.row2.4 -- run only the row: 4 in the second examples with this tag:

      |     60 |     15 |     13 |

关于python - 使用行为标签仅执行此类标签的子案例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45186323/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com