Kỹ thuật hữu ích là "phân vùng tương đương" — chia input thành các nhóm mà code xử lý khác nhau, rồi lấy đại diện mỗi nhóm cộng với các điểm biên giữa chúng.
Ví dụ bài tìm số trong mảng sorted: nhóm "có trong mảng" (đầu, giữa, cuối), nhóm "không có" (nhỏ hơn min, lớn hơn max, ở giữa hai phần tử), và biên (mảng rỗng, một phần tử, duplicate).
Use equivalence partitioning: split inputs into groups the code treats differently, then pick one representative per group plus the boundaries between them.
- For searching a sorted array: present (first, middle, last), absent (below min, above max, between elements), and boundaries (empty, single, duplicates).
- For numbers, always consider 0, negatives, and overflow-sized values; for strings, empty, single char, all-same, and unicode.
- Aim to cover logic branches, not to maximize test count.