学习 Linux 下使用 Postman 进行接口测试,可以按下面几个阶段循序渐进来学,既包含 Linux 使用,也包含 Postman 本身。
Postman 在 Linux 上主要用来测接口,但你需要会用 Linux:
pwd # 当前目录
ls -l # 查看文件
cd /path # 切换目录
mkdir test # 建目录
touch a.sh # 建文件
cat file # 看内容
vim file # 编辑文件
chmod +x # 给执行权限
curl http://localhost:8080/api
ping www.baidu.com
netstat -tunlp | grep 8080
ps -ef | grep java
✅ 目的:确认服务在跑、端口在监听
https://www.postman.com/downloads/
tar -xvf Postman-linux-x64-*.tar.gz
./Postman/Postman
服务器一般用 Newman(Postman 命令行版)
npm install -g newman
newman run test.json
http://ip:端口/api示例:
GET http://192.168.1.10:8080/user/list
✅ GET(查)
✅ POST(增)
✅ PUT(改)
✅ DELETE(删)
POST 示例:
{
"username": "test",
"password": "123456"
}
在 Tests 标签里写:
pm.test("状态码是200", function () {
pm.response.to.have.status(200);
});
pm.test("返回包含token", function () {
pm.expect(pm.response.text()).to.include("token");
});
java -jar app.jar
netstat -tunlp | grep 8080
http://服务器IP:8080/api/login
newman run api_test.postman_collection.json
如果你愿意,可以告诉我:
✅ 你是 开发 / 测试 / 运维
✅ 是 本地 Linux 还是服务器
✅ 主要测 什么接口(HTTP / HTTPS / WebSocket)
我可以直接给你针对性学习路线 + 示例。