我是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.