我是Cucumber测试框架的新手,我应该使用黄瓜来测试REST API。我们可以说有一个REST API和端点http://localhost:8080/REST/coffee/search ,并接受三个查询参数“type”,“toppings”和“cost”。有几个组合的查询参数是可能的。编写用于测试REST API的黄瓜场景
我的问题是在写作场景来测试这个API。我想通过使用这些查询参数的几个组合来调用API。 但我在使用数据表或方案大纲之间感到困惑。
With Data Tables: //data is sent inside StepDefinition method as Data Table
Scenario: User Searches for Coffee
Given Coffee exists with valid data
|type |toppings | cost |
|Latte | | 1 |
|Espresso |Whipped Cream | 2 |
|Espresso | | 3.5 |
When User call the API with given data
Then Verify API Response for status
With Scenario Outline: // data is sent to individual params of stepdefinition.
Scenario Outline: User Searches for Coffee
Given Coffee exists with valid data <type>, <toppings>, <cost>
When User call the API with given data
Then Verify API Response for status
Examples:
|type |toppings | cost |
|Latte | | 1 |
|Espresso |Whipped Cream | 2 |
|Espresso | | 3.5 |
是否可以在场景大纲中获取数据表,如果我尝试类似下面的内容?
Scenario Outline: User Searches for Coffee
Given Coffee exists with valid data
When User call the API with given data
Then Verify API Response for status
Examples:
|type |toppings | cost |
|Latte | | 1 |
|Espresso |Whipped Cream | 2 |
|Espresso | | 3.5 |
Since I have 10+ query params to use, Please suggest some best practices too.