【发布时间】:2019-03-14 14:12:12
【问题描述】:
需要测试以 Json 作为响应的 GET。我在官方文档中没有找到有用的信息。
Feature: API_Retrieving_Platforms
As an authorized user...
@mytag
Scenario: Perform Get request
Given I am an authorized user
When I perform GET request "/api/hotels/lists/platforms",
Then I receive a JSON in response:
"""
[
{
"refId": 1,
"label": "Mobile"
},
{
"refId": 2,
"label": "Desktop"
}
]
"""
获取Json的步骤是:
[Then(@"I receive a JSON in response:")]
public void ThenIReceiveAJSONInResponse(string JSON)
{
Assert.Equal(HttpStatusCode.OK, _responseMessage.StatusCode);
}
【问题讨论】:
-
这并不是 Gherkin 的真正用途。老实说,我只会用 C# 编写这些测试,而忘记 Gherkin 语言。
标签: automated-tests cucumber specflow gherkin