본문 바로가기

🎪 놀고있네/Postman7

[Postman] Test Script 사용하기 - SKIP 케이스 만들기( pm.test.skip) 테스트해볼 사이트는 https://jsonplaceholder.typicode.com/ 여기이고, 무료로 해볼수있는게 많다. TC 중에 PASS, FAIL 외에도 SKIP 이 필요한 케이스가 있을 수 있어, 테스트 스크립트고 SKIP 케이스를 만들어 볼거다. GET 메소드 사용해서 나온 결과는 아래와 같다 GET https://jsonplaceholder.typicode.com/comments?postId=1 여기서 리스트에 id가 4인 경우는 SKIP 케이스로, 그 외에 id는 PASS 케이스로 작성해보면 아래와같다. const responseJson = pm.response.json(); for(i = 0; i < responseJson.length ; i++){ // id가 4가 아닐 때 pass.. 2023. 1. 3.
[Postman] Test Script 사용하기 - 데이터 타입 확인하기 예시로 테스트 해볼 수 있는 사이트들이 꽤 있는데, https://jsonplaceholder.typicode.com/ 여기서 특정 데이터가 가지는 데이터 타입을 테스트해볼 수 있는 테스트 스크립트이다. 위와 같은 body 를 가진 데이터가 있을 때, 타입을 확인하는 테스트 스크립트는 아래와 같다. 데이터 구조에 따라 다르겠지만 참고하길 바람! // Asserting a value type const responseJson = pm.response.json(); pm.test("Test data type of the response", () => { pm.expect(responseJson).to.be.an("array"); pm.expect(responseJson[0].id).to.be.a("numbe.. 2022. 4. 6.
[Postman] Test Script 사용하기 - string 확인하기 테스트해볼 사이트는 https://jsonplaceholder.typicode.com/ 여기이고, 무료로 해볼수있는게 많으당!! /user 에서 GET 메소드 사용해서 나온 결과는 아래와 같다 user 데이터가 10개 정도 있는데 id 5 번 사람의 데이터를 확인해보고 이름이 'Chelsey Dietrich' 라는 걸 확인햇다. reponse에서 text를 추출했을 때 거기에 '이름' 이 있다면 테스트 결과는 PASS 로 나온다. 만약에 이사람 이름이 id 10번에 있다고 하고 호출을하면 다른값이 나오기 때문에 Test 결과는 FAIL 로 나온당. 2021. 12. 18.
[Postman] Test Script 사용하기 - jsonBody status, jsonBody 사용해보기 Test 탭에 스크립트 작성 후 Send 버튼 클릭 pm.test("response is ok", function () { pm.response.to.have.status(200); }); pm.test("response body has json with form data", function () { pm.response.to.have.jsonBody('form.foo1', 'bar1') .and.have.jsonBody('form.foo2', 'bar2'); }); Raw 데이터 추출 Send 버튼 클릭 https://learning.postman.com/docs/writing-scripts/test-scripts/ Home Postman Network Brow.. 2021. 9. 30.
[Postman] Pre-request Script, Test Script 차이 포스트맨에는 테스트 스크립트를 작성할 수 있는 기능이 있는데, 요청이 서버로 가기 전에 실행되는 Pre-request Script 요청이 서버로 간 이후 응답이 반환된 후에 실행되는 Test Script Pre-request Script Request 헤더에 key를 추가시키거나, URL 매개변수에 문자열을 추가하고자 할 때 사용할 수 있음 Test Script .test 함수를 사용하고, .response, .expect 객체 등에 접근이 가능함 https://learning.postman.com/docs/writing-scripts/intro-to-scripts/ Home Postman Network Browse APIs, workspaces, and collections inside Postman... 2021. 7. 23.
[Postman] API 테스트해보기 - GET Method 간단하게 GET 메소드 사용해서 응답 확인해보기 테스트해볼 수 있는 사이트 https://jsonplaceholder.typicode.com/ JSONPlaceholder - Free Fake REST API {JSON} Placeholder Free fake API for testing and prototyping. Powered by JSON Server + LowDB As of Dec 2020, serving ~1.8 billion requests each month. jsonplaceholder.typicode.com 기본 URL 입력하고 Send 보내면, html 읽어옴 테스트 사이트에서 공통 자원에 대해 아래와 같이 지원하길래 아무거나 한번 해봄 users 자원에 접근해서 body 값 가져오기.. 2021. 6. 11.
[Postman] postman 설치하기 https://www.postman.com/ Postman | The Collaboration Platform for API Development Postman makes API development easy. Our platform offers the tools to simplify each step of the API building process and streamlines collaboration so you can create better APIs faster. www.postman.com 가입하고 로그인 https://www.postman.com/downloads/ Download Postman | Try Postman for Free Try Postman for free! Join 13 mi.. 2021. 6. 11.