Việc nhập dữ liệu kiểm thử từ file CSV/Excel vào Postman có thể được thực hiện thông qua tính năng Data-Driven Testing. Dưới đây là hướng dẫn chi tiết:
1. Chuẩn bị File Dữ Liệu:
username,password,email
user1,pass1,user1@example.com
user2,pass2,user2@example.com
user3,pass3,user3@example.com
[
{
"username": "user1",
"password": "pass1",
"email": "user1@example.com"
},
{
"username": "user2",
"password": "pass2",
"email": "user2@example.com"
},
{
"username": "user3",
"password": "pass3",
"email": "user3@example.com"
}
]
2. Nhập Dữ Liệu vào Postman:
{{username}} và {{password}}.
3. Sử Dụng Biến trong Request:
{{variable_name}} để tham chiếu đến các giá trị từ file dữ liệu.{{username}} trong body của request.{
"username": "{{username}}",
"password": "{{password}}",
"email": "{{email}}"
}
4. Kiểm Tra Kết Quả:
Lưu ý:
Ví dụ cụ thể:
Giả sử bạn có một API POST để tạo người dùng. Bạn muốn kiểm thử API này với nhiều bộ dữ liệu khác nhau.
File CSV (users.csv):
username,password,email
testuser1,password123,test1@example.com
testuser2,securepass,test2@example.com
Request POST (Create User):
URL: https://api.example.com/users
Method: POST
Body (raw, JSON):
{
"username": "{{username}}",
"password": "{{password}}",
"email": "{{email}}"
}
Run Collection:
Postman sẽ chạy request hai lần, mỗi lần với một bộ dữ liệu từ file CSV. Bạn có thể kiểm tra kết quả của từng lần chạy để đảm bảo API hoạt động đúng.
🌱 Facebook
Fanpage: Anh Tester
🌱
Telegram Automation Testing:
Cộng đồng Automation Testing
🌱 Facebook Group Automation:
Cộng đồng Automation
Testing Việt Nam
🌱
Telegram Manual Testing:
Cộng đồng Manual Testing
🌱 Facebook
Group Manual:
Cộng đồng Manual Testing Việt Nam
Copyright © 2021-2025 Anh Tester Automation Testing
Anh Tester
Đường dẫu khó chân vẫn cần bước đi
Đời dẫu khổ tâm vẫn cần nghĩ thấu