Tools/Postman
API test in Postman
sunny.ryu
2022. 7. 11. 20:00
오른쪽의 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/
Understand JavaScript Callback Functions and Use Them
(Learn JavaScript Higher-order Functions, aka Callback Functions) In JavaScript, functions are first-class objects; that is, functions are of the type Object and they can be used in a first-class manner...
javascriptissexy.com