We have a feature A with several scenarios. And we need one scenario from that file. Can we call it in our feature B?
问问题
7032 次
2 回答
7
不可以。您需要将该场景提取到一个单独的文件中,然后使用关键字*.feature
重新使用它。call
编辑:空手道 0.9.0 及以后的版本将支持按标签调用,如下所示:
* def result = call read('some.feature@tagname')
于 2017-09-23T01:31:36.940 回答
0
用一个例子来说明空手道发明者彼得托马斯的答案:
给定一个带有标签装饰器标记的some.feature
多个场景的特征文件:
@tagname
Scenario: A, base case that shares results to e.g. B
// given, when, then ... and share result in a map with keyword `uri`
* def uri = responseHeaders['Location'][0]
@anotherTag
Scenario: X, base case that shares results to e.g. B
// given, when, then ... and share result in a map with keyword `createdResourceId`
* def createdResourceId = $.id
在另一个特性中,我们可以通过其标签从该特性中调用特定场景tagname
,例如:
Scenario: B, another case reusing some results of A
* def result = call read('some.feature@tagname')
* print "given result of A is: $result"
Given path result.uri + '/update'
另请参阅:向场景添加自定义标签的演示
于 2021-12-08T15:50:58.597 回答