我正在使用restAssured为我的JSON模式验证。 以下是我的断言脚本: String JsonString = response.asString(); Assert.assertEquals(JsonString,matchesJsonSchemaInClasspath(“quotesschema.json”));restAssured json模式验证 - 读取json模式文件断言失败
而且我已将我的quotesschema.json文件放在项目/ bin文件夹中。
当我运行我的测试脚本,断言失败下面的消息 java.lang.AssertionError:预期[],但发现[实际API响应]
另外,我验证了我对模式通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"
}
}
}
}
}
}
}