我在lettuce中寻找一种方法来指定从我的Gherkin功能文件运行的代码,以便在我到达@before.each_scenario
挂钩时它已经运行 - 这是本质上是为场景大纲做一组动态示例,所以给定一个具有事物目录的应用程序,我希望每个都能测试,我希望能够做如下的事情:
Feature: Automated Catalogue Test
In order to have use the system
As a user
I want to be able to use each feature in the catalogue
Background:
Given I start the system
And I have a list of features
@foreach
Scenario Outline: I use each feature in the system
Given feature <feature_num>
When I load the feature
And I use the feature in the way they are all used
Then I can clear up the feature
所以我有一个预先设置的示例列表,我已经能够通过使用钩子来扩展场景来测试逻辑,并且它可以工作,但这意味着如果一个功能失败了那些将不会运行。
如果后台步骤仅在@before.each_scenario
之前运行,那么我可以设置在outlines
枚举的lettuce/core.py:722
列表,但据我所知不是小黄瓜语言的一部分;我不想将I have a list of features
添加到地形中,因为还有许多其他测试不需要了解此目录......
我不认为有人有任何建议吗?
答案 0 :(得分:0)
目前作为折衷方案,我提出了这个问题:
Feature: Automated Catalogue Test
In order to have use the system
As a user
I want to be able to use each feature in the catalogue
@foreach @foreach_feature
Scenario Outline: I use each feature in the system
Given feature <feature_num>
When I load the feature
And I use the feature in the way they are all used
Then I can clear up the feature
然后我实现了查找@foreach
标记的钩子,我在标记注册表中添加了一个查找,如果找到@foreach_feature
标记,我已经存储了一个回调来运行。这仍然看起来不太理想,但我会把它放在那里试图解决同样的问题,直到找到更好的解决方案。