简体   繁体   English

用黄瓜测试网络服务

[英]Testing web-service with cucumber

Need to test web-service with cucumber.需要用黄瓜测试网络服务。 I have file CreateDoc.feature with我有文件 CreateDoc.feature

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

And there is another file Revocation.feature where I need to use a variable that I recieve in CreateDoc.feature Scenario还有另一个文件 Revocation.feature 我需要使用我在 CreateDoc.feature Scenario 中收到的变量

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

How can I do that?我怎样才能做到这一点?

You can't actually pass data from one scenario to another.您实际上无法将数据从一个场景传递到另一个场景。 Each scenario should stand alone without depending on the execution of any other scenario.每个场景都应该是独立的,而不依赖于任何其他场景的执行。 In fact, you can't guarantee which scenario will be executed first, or if they are executed in parallel.事实上,你不能保证哪个场景会先执行,或者它们是否并行执行。 Feature files are a way of grouping scenarios that are related.功能文件是对相关场景进行分组的一种方式。

This means that a scenario may duplicate steps from other scenarios, explicitly or implictly.这意味着一个场景可能会从其他场景中明确或隐含地复制步骤。

Also remember that Gherkin should express the actions in terms of the business, not the underlying technology.还要记住,Gherkin 应该根据业务而不是底层技术来表达操作。

For your revocation scenario, you could try:对于您的撤销场景,您可以尝试:

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

The Given step would go through the entire document creation process. Given 步骤将贯穿整个文档创建过程。

The When step would perform the necessary action to revoke the document When 步骤将执行必要的操作来撤销文档

The Then step would test, perhaps by looking up the document num, that the document was correctly processed. Then 步骤可能会通过查找文档编号来测试文档是否被正确处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM