Kỹ thuật testing
[Q&A] Cách đặt tên test case sao cho ngắn gọn, dễ hiểu. Liệu có 1 quy chuẩn nào không?

Hỏi
Cách đặt tên test case sao cho ngắn gọn, dễ hiểu. Liệu có 1 quy chuẩn nào không?
Đáp
Có nhiều quy chuẩn và best practices cho việc đặt tên test case. Dưới đây là một số những nguyên tắc phổ biến nhất.
Test Case ID vs Test Case Title
Test Case ID (Mã định danh)
TC_LOGIN_001
TC_CART_025
WEB_REG_103
→ Ngắn gọn, duy nhất, dùng để tracking
Test Case Title (Tiêu đề/Tên)
"Verify user can login successfully with valid email and password"
"Check error message when entering invalid email format"
"Validate shopping cart updates quantity correctly"
→ Mô tả đầy đủ, dễ hiểu mục đích test
Quy chuẩn đặt Test Case Title
1. Pattern: Action + What + Condition
Verify/Check/Validate + [Chức năng] + [Điều kiện]
Ví dụ:
- “Verify login functionality with valid credentials”
- “Check password reset link expires after 24 hours”
- “Validate error message for empty required fields”
2. Pattern: User Story Style
User should be able to + [Action] + [Context]
Ví dụ:
- “User should be able to login with valid email and password”
- “User should not be able to checkout with empty cart”
- “Admin should be able to view all user reports”
3. Pattern: Expected Result Focus
[Feature] displays/shows/returns [Expected Result] when [Condition]
Ví dụ:
- “Login page displays error message when password is incorrect”
- “Search returns relevant products when using filters”
- “System shows 404 page when accessing invalid URL”
Best Practices cho Test Case Title
✅ NÊN:
- Bắt đầu bằng động từ hành động:
- Verify, Validate, Check, Ensure, Confirm
- Test (tránh dùng vì hiển nhiên rồi)
- Rõ ràng về điều kiện test:
- “…with valid data”
- “…when field is empty”
- “…after session timeout”
- Độ dài vừa phải:
- Không quá ngắn: ❌ “Login test”
- Không quá dài: ❌ “Verify that when user enters valid email address in email field and valid password in password field and clicks on login button then user should be successfully logged in and redirected to dashboard”
- Vừa đủ: ✅ “Verify successful login with valid credentials”
❌ TRÁNH:
- Mơ hồ: “Check login feature”
- Kỹ thuật quá: “Test API endpoint POST /api/v1/auth/login returns 200”
- Nhiều scenarios: “Test login with valid/invalid/empty credentials”
Ví dụ thực tế
Module: User Registration
ID: TC_REG_001
Title: "Verify successful registration with all required fields"
ID: TC_REG_002
Title: "Validate error message when email already exists"
ID: TC_REG_003
Title: "Check password strength indicator updates correctly"
ID: TC_REG_004
Title: "Ensure confirmation email is sent after successful registration"
Module: Shopping Cart
ID: TC_CART_001
Title: "Verify item is added to cart successfully"
ID: TC_CART_002
Title: "Validate cart total updates when quantity changes"
ID: TC_CART_003
Title: "Check cart persists after user logs out and logs back in"
ID: TC_CART_004
Title: "Verify coupon code applies correct discount"
Template chuẩn cho team:
Test Case ID: [PREFIX]_[MODULE]_[NUMBER]
Test Case Title: [Action Verb] + [Feature/Function] + [Condition/Context]
Ví dụ:
ID: TC_LOGIN_001
Title: "Verify successful login with valid username and password"
ID: TC_LOGIN_002
Title: "Validate account lockout after 5 failed login attempts"
Tips:
- Title phải tự giải thích – Người đọc hiểu ngay test gì mà không cần đọc steps
- Tránh quá “technical” nếu test case cho BA/khách hàng đọc
- Theo một format – Cả team dùng chung một format
- Có thể tìm kiếm – Dùng keywords dễ tìm kiếm
