Newman 은 Postman의 Collection을 커맨드 라인에서 실행시켜준다!
전체적인 순서
1. Install node.js
2. Install newman
3. export collection and run from commandline
4. On cmd goto location of collection json file
5. Run command
check if node.js is already installed
cmd 창에서 아래와 같이 확인
node -v
npm -v
1. Install node.js
만약 설치가 안되어있다면 아래 URL 참고하여 설치
https://nodejs.org/en/download/
Download | Node.js
Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.
nodejs.org
2. Install Newman
cmd 창에서 아래 명령어로 뉴맨 설치!
npm install -g newman
3. Export collection as json file
4. On cmd goto location of collection json file
5. Run command
예시 : newman run (exprot한 json 파일 명)
newman run collectionfilename.json
실행 화면
C:\Users\toast\Desktop\Postman>newman run Collection1.postman_collection.json
newman
Collection1
□ GET
└ GET User
┌
│ 'Hello world...'
│ 'Value for url variables is : https://reqres.in'
│ 'POSTMAN'
│ undefined
└
GET https://reqres.in/api/users/2 [200 OK, 1.08KB, 249ms]
┌
│ 'Hello world...'
│ 'Value for url variables is : https://reqres.in'
│ 'POSTMAN'
│ undefined
└
└ GET UserList
┌
│ 'Hello world...'
│ 'Value for url variables is : https://reqres.in'
│ 'POSTMAN'
│ undefined
└
GET https://reqres.in/api/users?page=2 [200 OK, 1.78KB, 47ms]
√ Verify Response time is less than 200ms
√ Verify Status code is 200
└ ScriptsTest
┌
│ 'Hello world...'
│ 'Value for url variables is : https://reqres.in'
│ 'POSTMAN'
│ undefined
└
GET [errored]
runtime:extenstions~request: request url is empty
□ POST
└ User Registration
┌
│ 'Hello world...'
│ 'Value for url variables is : https://reqres.in'
│ 'POSTMAN'
│ undefined
└
GET [errored]
runtime:extenstions~request: request url is empty
┌─────────────────────────┬────────────────────┬────────────────────┐
│ │ executed │ failed │
├─────────────────────────┼────────────────────┼────────────────────┤
│ iterations │ 1 │ 0 │
├─────────────────────────┼────────────────────┼────────────────────┤
│ requests │ 4 │ 2 │
├─────────────────────────┼────────────────────┼────────────────────┤
│ test-scripts │ 6 │ 0 │
├─────────────────────────┼────────────────────┼────────────────────┤
│ prerequest-scripts │ 5 │ 0 │
├─────────────────────────┼────────────────────┼────────────────────┤
│ assertions │ 2 │ 0 │
├─────────────────────────┴────────────────────┴────────────────────┤
│ total run duration: 729ms │
├───────────────────────────────────────────────────────────────────┤
│ total data received: 1.58KB (approx) │
├───────────────────────────────────────────────────────────────────┤
│ average response time: 148ms [min: 47ms, max: 249ms, s.d.: 101ms] │
└───────────────────────────────────────────────────────────────────┘
# failure detail
1. Error runtime:extenstions~request: request url is empty
at request
inside "GET / ScriptsTest"
2. Error runtime:extenstions~request: request url is empty
at request
inside "POST / User Registration"
Jenkins 활용 관련
아래와 같이 Newman 명령어로 JOB 생성하여 진행