用黄瓜测试网络服务

时间:2017-10-16 15:03:45

标签: java web-services testing cucumber

需要用黄瓜测试网络服务。 我有文件CreateDoc.feature with

Scenario: recieve document num
Given sender info
And manufacturer code 3
When colling web-service
Then recieve document num 

还有另一个文件Revocation.feature,我需要使用我在CreateDoc.feature场景中收到的变量

Scenario: revocation doc
Given //need document num from first scenario

我该怎么做?

1 个答案:

答案 0 :(得分:1)

您实际上无法将数据从一个方案传递到另一个方案。每个方案都应该独立,而不依赖于任何其他方案的执行。实际上,您无法保证首先执行哪种方案,或者它们是否并行执行。功能文件是一种对相关场景进行分组的方法。

这意味着场景可能会明确地或隐含地复制其他场景中的步骤。

还要记住,Gherkin应该根据业务而不是基础技术来表达行动。

对于您的撤销方案,您可以尝试:

Given I've created a document identified by document num
When I revoke the document
Then it should be gone

Given步骤将贯穿整个文档创建过程。

When步骤将执行撤消文档的必要操作

然后,步骤将通过查找文档num来测试文档是否已正确处理。