简体   繁体   中英

Testing web-service with cucumber

Need to test web-service with cucumber. I have file CreateDoc.feature with

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

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.

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.

The When step would perform the necessary action to revoke the document

The Then step would test, perhaps by looking up the document num, that the document was correctly processed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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