在 CentOS 上安装与启动
wget https://dl.pstmn.io/download/latest/linux64 -O postman.tar.gz
sudo mkdir -p /opt
sudo tar -xzf postman.tar.gz -C /opt
sudo ln -sfn /opt/Postman/Postman /usr/bin/postman
postman
[Desktop Entry]
Encoding=UTF-8
Name=Postman
Exec=/usr/bin/postman
Icon=/opt/Postman/app/resources/app/assets/icon.png
Terminal=false
Type=Application
Categories=Development;
StartupNotify=true
sudo chmod +x /usr/share/applications/postman.desktop
sudo update-desktop-database
以上步骤适用于 CentOS 7/8/Stream,图形环境为 GNOME/KDE 均可。
图形界面快速上手
pm.test("Status code is 200", () => pm.response.to.have.status(200));
pm.test("Body has id", () => {
const json = pm.response.json();
pm.expect(json.id).to.be.a('number');
});
命令行与自动化
sudo yum install -y nodejs npm
sudo npm install -g newman
newman run collection.json
newman run collection.json -e dev.env.json -r cli,html --reporter-html-export report.html
Newman 适合在 CI/CD、服务器定时任务中执行接口自动化与回归测试。
常见问题与排错
sudo yum install -y libXScrnSaver
which postman
echo $PATH