Automation/Postman

Postman - new man

c29130811 2023. 2. 18. 14:51

Postman에 구성 된 Collection을 command line으로 진행할 수 있는 기능

 

https://learning.postman.com/docs/running-collections/using-newman-cli/command-line-integration-with-newman/

 

Running collections on the command line with Newman | Postman Learning Center

Running collections on the command line with Newman: documentation for Postman, the collaboration platform for API development. Create better APIs—faster.

learning.postman.com

 

Postman GUI에서 Collection 의 메뉴 중 Export를 통해 Json 으로 된 Collection 을 다운 받을 수 있다.

필요한 Environments도 동일하게 다운로드 받는다.

 

npm project를 하나 생성 후 newman을 설치

$ npm install newman

그리고 project 폴더에 collection.json과 environment.json을 이동하고, index.js에 아래 내용을 입력한다.

const newman = require('newman');

newman.run({
  collection: require('./regression.postman_collection.json'),
  environment: require('./dev.postman_environment.json'),
  reporters: 'cli'
}, function (err) {
  if (err) { throw err; }
  console.log('collection run complete!');
});

이제 node index.js 를 실행하면 terminal에서 postman 내용이 실행되는 걸 볼 수 있다.

pipeline으로 api 에 변동이 생길 때마다 돌려도 좋을 것 같음.

728x90

'Automation > Postman' 카테고리의 다른 글

Postman Flows  (0) 2023.04.28
Postman - validation  (0) 2023.02.18
Environment  (0) 2020.09.23
Tests  (0) 2020.09.22
Postman  (0) 2020.09.22