2018년 10월 29일 월요일

Json schema test 방법

1. Json Shechma 생성
https://jsonschema.net/#/
Number Type에 대해 체크
2. 생성된 스키마에서 required 부분 확인할 것
-> API 명세에서 response에 대한 필수값이 체크되지 않았으면 json schema 에서 required 부분을 꼭 확인하여 필수값이 아닌 키값에 대해서 삭제해주자.

3. RestAussured 확인
 1) 1번에서 생성한 스키마를 test/resources 에 json 파일로 저장
 2) .body(matchesJsonSchemaInClasspath("cancellations_json_schema.json"))

4. Postman 확인
 1) 1번에서 생성한 스키마를 enviornment에 저장
 2) pm.test("schema check", function(){
    pm.expect(tv4.validate(pm.response.json(), pm.environment.get("cancel_schema"), false, true), tv4.error).to.be.true;
})

댓글 없음:

댓글 쓰기