作为示例,我尝试使用匹配包含来验证我的架构响应和数据类型,有时它返回 null,有时它会返回字符串。我正在尝试以下操作,但断言失败,因为它的计算结果不为 true。
我正在尝试以下操作:
* match each $response.data.Results contains
"""
{
"providerID": '#number',
"firstName": "#? _ == '#string' || _ == '#null'",
"lastName": '#string',
"mI": "#? _ == '#string' || _ == '#null'",
"title": '#string',
"name": '#string',
"nameLFMT": '#string',
"status": '#string',
"specialties": '#array',
"locations": '#array',
"institutions": '#array',
"acceptNewPatient": '#string',
"imageUri": '#string',
"nearestLatitude": '#number',
"nearestLongitude": '#number'
}
"""
例如“firstName”返回的数据为“firstName”:null,
每次比赛前我都会发送以下信息:
Scenario: SearchResults
#Verify 200 response status returned
Given text query =
"""
{
Results: getSearchResults(searchLatitude:"48.942833",
searchLongitude: "-119.984549",
providerType: "Primary Care Physicians",
sortBy: "distance",
maxDistance:"600",
skip: 0,
take: 10) {
providerID
firstName
lastName
mI
title
name
nameLFMT
status
specialties
locations
institutions
acceptNewPatient
imageUri
nearestLatitude
nearestLongitude
}
}
"""
And request { query: '#(query)' }
When method post
Then status 200
我没有定义架构,我还没有弄清楚如何做到这一点,所以我不确定这是否是我的问题。我知道这可能是我应该这样做的,但我仍在学习。
谢谢你的帮助。