오른쪽의 SNIPPETS에서 Status code is 200을 클릭하면
Tests에 자동으로 form이 채워짐.
그 다음 Send 클릭!
Test Results를 확인할 수 있다.
Tip: make sure your tests FAIL!
일부러 존재하지 않는 주소를 입력하고 Send 클릭
그럼 404 Not Found 에러가 반환됨
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
- pm.test - function for writing test specifications
- works in a non-blocking way in case of errors
- can include multiple related assertions
- The first parameter is the test name, as a String
- The second parameter is a so-call callback function which is called when the underlying execution (in this case assertions) has finished
- pm.response - is the response assertion API and can make assertions on the response object (status code, headers, body)
http://javascriptissexy.com/understand-javascript-callback-functions-and-use-them/
'Tools > Postman' 카테고리의 다른 글
Testing an API(feat. The Trello REST API) (0) | 2022.07.11 |
---|---|
POST request practice (0) | 2022.07.10 |
HTTP headers (0) | 2022.07.10 |
API Authentication (0) | 2022.07.10 |
Troubleshooting Postman errors (0) | 2022.07.05 |