Skip to Content
Suffering builds character

7.API 테스트

1. 시나리오

서버는 정상적으로 실행 되었지만, 운영 환경에서 잘 동작하는지 간단한 API 호출 테스트가 필요할 경우,

REST API 또는 헬스체크 엔드포인트를 확인하기 위해서는 curl, wget 등을 활용할 수 있음

2. 실습 명령어

terminal
# curl 사용 # -w "\n": 마지막에 개행 추가 curl http://localhost:8080/actuator/health -w "\n" curl -X POST -H "Content-Type: application/json" -d '{"name":"test"}' http://localhost:8080/api/users -w "\n" # wget 사용 # ../health; echo로 강제 개행 wget -qO- http://localhost:8080/actuator/health; echo

3. 명령어 설명

  • curl : HTTP 요청 전송, GET/POST 테스트 가능
  • wget -qO- : 응답 내용을 콘솔로 출력
  • API 헬스체크, 간단한 테스트 시 활용
Last updated on