【发布时间】:2016-01-20 10:57:08
【问题描述】:
我正在使用 restAssured 进行我的 json 架构验证。 下面是我的断言脚本: 字符串 JsonString = response.asString(); Assert.assertEquals(JsonString,matchesJsonSchemaInClasspath("quotesschema.json"));
我已经把我的quotesschema.json 文件放在了project/bin 文件夹中。
当我运行我的测试脚本时,断言失败并显示以下消息 java.lang.AssertionError: expected [] but found [actual api response]
此外,我通过 http://json-schema-validator.herokuapp.com/ 架构验证器针对 api 响应验证了我的架构。
不确定它是否在 .son 文件中读取我的架构。 下面是我的架构。
{
"type": "object",
"$schema": "http://json-schema.org/draft-03/schema",
"title": "quotes-schema",
"description": "JSON Schema for Quotes",
"properties": {
"result": {
"type": "object",
"properties": {
"Quotes": {
"type": "array",
"properties": {
"DisplaySymbol": {
"type": "string"
},
"Identifier": {
"type": "string"
},
"Exchange": {
"type": "string"
},
"Trade": {
"type": "string"
},
"Date": {
"type": "string"
},
"Change": {
"type": "string"
},
"Bid": {
"type": "string"
},
"BidSize": {
"type": "string"
},
"Ask": {
"type": "string"
},
"AskSize": {
"type": "string"
},
"High": {
"type": "string"
},
"Low": {
"type": "string"
},
"Volume": {
"type": "string"
},
"Open": {
"type": "string"
},
"PreviousClose": {
"type": "string"
},
"High52Week": {
"type": "string"
},
"High52WeekDate": {
"type": "string"
},
"Low52Week": {
"type": "string"
},
"Low52WeekDate": {
"type": "string"
},
"PERatio": {
"type": "string"
},
"MarketCap": {
"type": "string"
},
"SharesOutstanding": {
"type": "string"
},
"RollingEPS": {
"type": "string"
},
"IsDefault": {
"type": "string"
},
"IsIndex": {
"type": "string"
},
"Class": {
"type": "string"
}
}
}
}
}
}
}
【问题讨论】:
标签: rest-assured json-schema-validator