0
我正在使用Json Schema Valuation和Rest Assured api。我正在從Web服務獲取Json響應,並使用此架構進行驗證。 當我更改架構中的屬性並運行測試代碼時,測試不會失敗。但我想測試一下那裏的任何財產。如果模式中的某個屬性在響應測試中不存在,則必須失敗。但我無法做到這一點。 我該怎麼做? 我的測試代碼:Json Schema驗證不失敗
@Test
public void catalogButiqueDetailTest(){
File file = new File("src/test/resources/generatedJson/boutiqueDetailSchema.json");
JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.newBuilder().setValidationConfiguration(ValidationConfiguration.newBuilder().setDefaultVersion(SchemaVersion.DRAFTV4).freeze()).freeze();
given()
.headers("some-header-info")
.contentType("application/json")
.get("web-service-url")
.then()
.assertThat()
.body(JsonSchemaValidator.matchesJsonSchema(file).using(jsonSchemaFactory));
}