# 📚 เอกสารประกอบการสอน สัปดาห์ที่ 5

# Black Box Testing Techniques (เทคนิคการทดสอบกล่องดำ)

---

## ส่วนที่ 1: เอกสารบรรยาย (Lecture Notes) - 2 ชั่วโมง

---

## 🎯 วัตถุประสงค์การเรียนรู้ (Learning Objectives)

เมื่อจบบทเรียนนี้ นิสิตจะสามารถ:

1. อธิบายแนวคิดและหลักการของ Black Box Testing (Explain concepts and principles)
2. ประยุกต์ใช้เทคนิค Equivalence Partitioning (EP) ในการออกแบบ test cases (Apply EP technique)
3. ใช้ Boundary Value Analysis (BVA) เพื่อหาข้อผิดพลาดที่ขอบเขต (Use BVA to find boundary errors)
4. สร้าง Decision Table สำหรับทดสอบ business rules ที่ซับซ้อน (Create Decision Tables)
5. ใช้ State Transition Testing กับระบบที่มีการเปลี่ยนสถานะ (Apply State Transition Testing)
6. เลือกใช้เทคนิคที่เหมาะสมกับปัญหาที่แตกต่างกัน (Select appropriate techniques)

---

## 📖 เนื้อหาบรรยาย (Lecture Content)

### 1. Black Box Testing: Overview - ภาพรวมการทดสอบกล่องดำ

#### 1.1 Black Box Testing คือ อะไร? (What is Black Box Testing?)

**Black Box Testing** เป็นเทคนิคการทดสอบที่:

- **ไม่จำเป็นต้องรู้โครงสร้างภายใน** (Don't need to know internal structure) ของโปรแกรม (source code)
- **ทดสอบจาก perspective ของผู้ใช้งาน** (Test from user perspective)
- **เน้นที่ Input และ Output** - ตรวจสอบว่าให้ผลลัพธ์ตรงตาม requirements หรือไม่
- เรียกอีกชื่อว่า **Specification-based Testing** หรือ **Behavioral Testing**

#### 1.2 ข้อดีของ Black Box Testing (Advantages)

✅ **ไม่ต้องมีความรู้ด้าน Programming** (No programming knowledge needed) - Tester ไม่ต้องเป็น Developer  
✅ **ตรงกับมุมมองผู้ใช้จริง** (Matches real user perspective) - ทดสอบในแบบที่ user จะใช้งาน  
✅ **ทดสอบได้ตั้งแต่เริ่มต้น** (Can test early) - ทำพร้อมกับที่ได้ Requirements  
✅ **หาข้อผิดพลาดที่ developers มักพลาด** (Find developer oversights) - Missing functionality, requirement errors  
✅ **เหมาะกับการทดสอบขนาดใหญ่** (Suitable for large-scale testing) - System testing, UAT

#### 1.3 ข้อจำกัดของ Black Box Testing (Limitations)

❌ **Coverage ไม่ครอบคลุม 100%** (Not 100% coverage) - ไม่สามารถทดสอบทุก path ได้  
❌ **อาจมี test cases ซ้ำซ้อน** (May have redundant tests) - ถ้าไม่ใช้เทคนิคที่ดี  
❌ **ไม่เห็นปัญหาภายใน code** (Can't see code issues) - Logic errors, code quality issues  
❌ **ใช้เวลามากถ้าทดสอบแบบสุ่ม** (Time consuming if random) - ต้องใช้เทคนิคที่เป็นระบบ

#### 1.4 เมื่อไหร่ควรใช้ Black Box Testing? (When to use?)

- ✅ Functional Testing - ทดสอบฟังก์ชันการทำงาน
- ✅ System Testing - ทดสอบระบบทั้งหมด
- ✅ Acceptance Testing - UAT, Beta Testing
- ✅ Integration Testing (บางส่วน) - ทดสอบ interface ระหว่าง modules

---

### 2. Equivalence Partitioning (EP) - การแบ่งข้อมูลทดสอบ

#### 2.1 แนวคิดพื้นฐาน (Basic Concept)

**Equivalence Partitioning (EP)** คือการแบ่ง input space ออกเป็นกลุ่ม (partitions) โดย:

- **Data ในกลุ่มเดียวกันควรได้ผลลัพธ์เหมือนกัน** (Data in same group should give same result)
- **เลือกทดสอบเพียง 1 ค่า จากแต่ละ partition** (Choose 1 value per partition)
- ช่วย**ลดจำนวน test cases** (Reduce test cases) แต่ยังคง**ครอบคลุมทั้งหมด** (Still comprehensive)

#### 2.2 ประเภทของ Partitions (Types of Partitions)

1. **Valid Partitions** - ข้อมูลที่ถูกต้อง (ควรทำงาน)
2. **Invalid Partitions** - ข้อมูลที่ผิด (ควรแสดง error)

#### 2.3 ตัวอย่างที่ 1: Age Input - อายุ (เข้าใจง่าย)

**Requirement:** ระบบรับอายุ 18-65 ปี

**การแบ่ง Partitions:**

| Partition ID | Description        | Type    | Example Values | Expected Result                  |
| ------------ | ------------------ | ------- | -------------- | -------------------------------- |
| P1           | อายุน้อยกว่า 18    | Invalid | 5, 10, 17      | Error: "Age must be 18 or above" |
| P2           | อายุ 18-65         | Valid   | 18, 30, 50, 65 | Accepted                         |
| P3           | อายุมากกว่า 65     | Invalid | 66, 80, 100    | Error: "Age must be 65 or below" |
| P4           | ข้อมูลไม่ใช่ตัวเลข | Invalid | "abc", "@#$"   | Error: "Age must be a number"    |
| P5           | ค่าว่าง            | Invalid | "", null       | Error: "Age is required"         |
| P6           | ตัวเลขติดลบ        | Invalid | -5, -20        | Error: "Age must be positive"    |

**Test Cases:**

```
TC01: Input = 10     → Expected: Error "Age must be 18 or above"
TC02: Input = 25     → Expected: Accepted
TC03: Input = 70     → Expected: Error "Age must be 65 or below"
TC04: Input = "abc"  → Expected: Error "Age must be a number"
TC05: Input = ""     → Expected: Error "Age is required"
TC06: Input = -5     → Expected: Error "Age must be positive"
```

#### 2.4 ตัวอย่างที่ 2: Library System - Book Search - ค้นหาหนังสือ

**Requirement:** ระบบค้นหาหนังสือด้วย keyword (3-50 ตัวอักษร)

**การแบ่ง Partitions:**

| Partition ID | Description              | Type          | Example                      | Expected Result                                |
| ------------ | ------------------------ | ------------- | ---------------------------- | ---------------------------------------------- |
| P1           | Keyword < 3 chars        | Invalid       | "ab", "x"                    | Error: "Keyword must be at least 3 characters" |
| P2           | Keyword 3-50 chars       | Valid         | "Java", "Python Programming" | Show search results                            |
| P3           | Keyword > 50 chars       | Invalid       | "a" × 51                     | Error: "Keyword too long"                      |
| P4           | Keyword ว่าง             | Invalid       | ""                           | Error: "Please enter search keyword"           |
| P5           | Keyword มี special chars | Valid/Invalid | "@#$%", "C++"                | ขึ้นกับ spec                                   |

**Test Cases:**

```javascript
// Test Data
TC01: keyword = "ab"; // Invalid - too short
TC02: keyword = "JavaScript"; // Valid - normal keyword
TC03: keyword =
  "Introduction to Software Testing and Quality Assurance Best Practices"; // Invalid - too long
TC04: keyword = ""; // Invalid - empty
TC05: keyword = "C++"; // Valid - with special chars
```

#### 2.5 Best Practices สำหรับ EP (Best Practices for EP)

✅ **พิจารณาทั้ง Valid และ Invalid partitions** (Consider both valid and invalid)  
✅ **แบ่ง partitions ให้ชัดเจน ไม่ทับซ้อน** (Clear, non-overlapping partitions)  
✅ **เลือกค่าตัวอย่างที่เป็นตัวแทนที่ดี** (Choose representative values)  
✅ **ครอบคลุมทุก business rules** (Cover all business rules)  
✅ **เขียนเอกสารการแบ่ง partitions ให้ชัดเจน** (Document clearly)

---

### 3. Boundary Value Analysis (BVA) - การวิเคราะห์ค่าที่ขอบเขต

#### 3.1 แนวคิดพื้นฐาน (Basic Concept)

**Boundary Value Analysis (BVA)** เป็นเทคนิคที่:

- **เน้นทดสอบค่าที่อยู่บริเวณขอบเขต** (Focus on boundary values)
- สถิติแสดงว่า **bugs มักเกิดที่ boundaries** - เช่น off-by-one errors
- เป็น**ส่วนเสริมของ EP** (Complements EP) - ใช้คู่กันเพื่อ maximize effectiveness

#### 3.2 กฎการเลือกค่าทดสอบ (Testing Rules)

สำหรับ range [min, max]:

- ทดสอบ **5 ค่า:**
  - `min - 1` (ก่อนขอบเขตล่าง) - Invalid
  - `min` (ขอบเขตล่าง) - Valid
  - `mid` (กลางช่วง) - Valid
  - `max` (ขอบเขตบน) - Valid
  - `max + 1` (หลังขอบเขตบน) - Invalid

#### 3.3 ตัวอย่างที่ 1: Age Input (18-65)

**Boundary Values:**

```
TC01: Age = 17   → Invalid (min - 1)
TC02: Age = 18   → Valid (min) ✓
TC03: Age = 40   → Valid (mid) ✓
TC04: Age = 65   → Valid (max) ✓
TC05: Age = 66   → Invalid (max + 1)
```

#### 3.4 ตัวอย่างที่ 2: Library System - Book Borrowing Limit

**Requirement:** สมาชิกยืมหนังสือได้ 1-5 เล่มต่อครั้ง

**Boundary Values:**

| Test Case | Books to Borrow | Expected Result                             |
| --------- | --------------- | ------------------------------------------- |
| TC01      | 0               | ❌ Error: "Must borrow at least 1 book"     |
| TC02      | 1               | ✅ Success - Minimum valid                  |
| TC03      | 3               | ✅ Success - Mid value                      |
| TC04      | 5               | ✅ Success - Maximum valid                  |
| TC05      | 6               | ❌ Error: "Cannot borrow more than 5 books" |

**JavaScript Test Code Example:**

```javascript
describe("Book Borrowing Boundary Tests", () => {
  test("TC01: Cannot borrow 0 books", () => {
    const result = borrowBooks(userId, 0);
    expect(result.success).toBe(false);
    expect(result.error).toContain("at least 1 book");
  });

  test("TC02: Can borrow 1 book (minimum)", () => {
    const result = borrowBooks(userId, 1);
    expect(result.success).toBe(true);
  });

  test("TC03: Can borrow 3 books (mid-range)", () => {
    const result = borrowBooks(userId, 3);
    expect(result.success).toBe(true);
  });

  test("TC04: Can borrow 5 books (maximum)", () => {
    const result = borrowBooks(userId, 5);
    expect(result.success).toBe(true);
  });

  test("TC05: Cannot borrow 6 books", () => {
    const result = borrowBooks(userId, 6);
    expect(result.success).toBe(false);
    expect(result.error).toContain("more than 5 books");
  });
});
```

#### 3.5 Robust Boundary Value Analysis

**Robust BVA** ทดสอบ boundaries ของ**ทุก input variables พร้อมกัน**

**ตัวอย่าง:** ระบบค้นหาหนังสือ (keyword: 3-50 chars, results per page: 10-100)

**Combinations:**

```
- (keyword=3, results=10)   → Both at minimum
- (keyword=3, results=100)  → Min keyword, Max results
- (keyword=50, results=10)  → Max keyword, Min results
- (keyword=50, results=100) → Both at maximum
- (keyword=2, results=10)   → Invalid keyword, valid results
- (keyword=3, results=9)    → Valid keyword, invalid results
```

**Note:** Robust BVA สร้าง test cases จำนวนมาก - ใช้ตาม risk และความสำคัญ

---

### 4. Decision Table Testing - การทดสอบด้วยตารางการตัดสินใจ

#### 4.1 แนวคิดพื้นฐาน (Basic Concept)

**Decision Table Testing** ใช้เมื่อ:

- ระบบมี **business rules ที่ซับซ้อน** (Complex business rules)
- มี **หลายเงื่อนไข (conditions)** ที่ต้องพิจารณาพร้อมกัน
- แต่ละ **combination ของเงื่อนไขให้ผลลัพธ์ต่างกัน**

**Decision Table ประกอบด้วย:**

1. **Conditions** - เงื่อนไขที่ต้องพิจารณา
2. **Actions** - การกระทำ/ผลลัพธ์
3. **Rules** - การผสมกันของเงื่อนไข

#### 4.2 ตัวอย่างที่ 1: Discount Calculation - คำนวณส่วนลด (เข้าใจง่าย)

**Business Rules:**

- ลูกค้าใหม่ (New) ไม่ได้ส่วนลด
- ลูกค้าเก่า (Regular) ได้ส่วนลด 10%
- ลูกค้า VIP ได้ส่วนลด 20%
- ซื้อมากกว่า $100 ได้ส่วนลดเพิ่ม 5%

**Decision Table:**

| Rule                    | R1     | R2     | R3      | R4      | R5      | R6      |
| ----------------------- | ------ | ------ | ------- | ------- | ------- | ------- |
| **Conditions**          |        |        |         |         |         |         |
| Customer Type = New     | T      | T      | F       | F       | F       | F       |
| Customer Type = Regular | F      | F      | T       | T       | F       | F       |
| Customer Type = VIP     | F      | F      | F       | F       | T       | T       |
| Purchase > $100         | F      | T      | F       | T       | F       | T       |
| **Actions**             |        |        |         |         |         |         |
| Base Discount           | 0%     | 0%     | 10%     | 10%     | 20%     | 20%     |
| Volume Discount         | 0%     | 5%     | 0%      | 5%      | 0%      | 5%      |
| **Total Discount**      | **0%** | **5%** | **10%** | **15%** | **20%** | **25%** |

**Test Cases:**

```
TC01 (R1): New customer, $50 purchase    → 0% discount
TC02 (R2): New customer, $150 purchase   → 5% discount
TC03 (R3): Regular, $50 purchase         → 10% discount
TC04 (R4): Regular, $150 purchase        → 15% discount
TC05 (R5): VIP, $50 purchase             → 20% discount
TC06 (R6): VIP, $150 purchase            → 25% discount
```

#### 4.3 ตัวอย่างที่ 2: Library System - Book Borrowing Rules

**Business Rules:**

1. สมาชิกต้อง**ไม่มีหนังสือค้าง** (No overdue books) ถึงจะยืมเพิ่มได้
2. สมาชิกประเภท **Standard** ยืมได้สูงสุด **3 เล่ม**
3. สมาชิกประเภท **Premium** ยืมได้สูงสุด **5 เล่ม**
4. หนังสือต้อง **Available** ถึงจะยืมได้

**Decision Table:**

| Rule                    | R1                     | R2                     | R3                     | R4                     | R5  | R6                  | R7   | R8                  |
| ----------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- | --- | ------------------- | ---- | ------------------- |
| **Conditions**          |                        |                        |                        |                        |     |                     |      |
| Has Overdue Books?      | T                      | T                      | T                      | T                      | F   | F                   | F    | F                   |
| Member Type             | Std                    | Std                    | Prem                   | Prem                   | Std | Std                 | Prem | Prem                |
| Current Borrowed < Max? | T                      | F                      | T                      | F                      | T   | F                   | T    | F                   |
| Book Available?         | T                      | T                      | T                      | T                      | T   | T                   | T    | T                   |
| **Actions**             |                        |                        |                        |                        |     |                     |      |
| Allow Borrow?           | ❌                     | ❌                     | ❌                     | ❌                     | ✅  | ❌                  | ✅   | ❌                  |
| Error Message           | "Return overdue books" | "Return overdue books" | "Return overdue books" | "Return overdue books" | -   | "Max limit reached" | -    | "Max limit reached" |

**Test Cases:**

```javascript
// R1: Standard member with overdue, under limit
{
  memberId: 'M001',
  memberType: 'Standard',
  currentBorrowed: 2,
  hasOverdue: true,
  bookId: 'B001',
  bookStatus: 'Available'
}
Expected: ❌ Error "Please return overdue books first"

// R5: Standard member, no overdue, under limit
{
  memberId: 'M002',
  memberType: 'Standard',
  currentBorrowed: 2,
  hasOverdue: false,
  bookId: 'B002',
  bookStatus: 'Available'
}
Expected: ✅ Success - Book borrowed

// R6: Standard member, no overdue, at limit
{
  memberId: 'M003',
  memberType: 'Standard',
  currentBorrowed: 3,
  hasOverdue: false,
  bookId: 'B003',
  bookStatus: 'Available'
}
Expected: ❌ Error "You have reached maximum borrowing limit (3 books)"
```

#### 4.4 สร้าง Decision Table - ขั้นตอน (Steps to Create)

1. **ระบุ Conditions** - เงื่อนไขทั้งหมดที่มีผล
2. **คำนวณ Rules** - จำนวน rules = 2^n (n = จำนวน conditions)
3. **กำหนด Actions** - ผลลัพธ์ของแต่ละ rule
4. **ลด Rules** - รวม rules ที่ให้ผลเหมือนกัน (ถ้าได้)
5. **สร้าง Test Cases** - อย่างน้อย 1 test case ต่อ rule

#### 4.5 Best Practices

✅ **ครอบคลุมทุก combinations ที่เป็นไปได้** (Cover all possible combinations)  
✅ **ตรวจสอบว่าไม่มี rules ขัดแย้งกัน** (Check for conflicting rules)  
✅ **ใช้กับ business rules ที่มี ≥ 3 conditions**  
✅ **Document ให้ชัดเจน** (Document clearly) - ใช้เป็น specification ได้

---

### 5. State Transition Testing - การทดสอบการเปลี่ยนสถานะ

#### 5.1 แนวคิดพื้นฐาน (Basic Concept)

**State Transition Testing** ใช้กับระบบที่:

- มี **สถานะ (states)** ต่างๆ
- แต่ละ **event/action** ทำให้เปลี่ยนสถานะ
- พฤติกรรม**ขึ้นกับสถานะปัจจุบัน** (Behavior depends on state)

**ตัวอย่างระบบที่ใช้:** ATM, Booking System, Order Processing, Game Character States

#### 5.2 State Transition Diagram Components (ส่วนประกอบ)

1. **States** (วงกลม/สี่เหลี่ยม) - สถานะของระบบ
2. **Transitions** (ลูกศร) - การเปลี่ยนสถานะ
3. **Events** (label บนลูกศร) - เหตุการณ์ที่ทำให้เปลี่ยนสถานะ
4. **Actions** (optional) - การกระทำเมื่อเปลี่ยนสถานะ

#### 5.3 ตัวอย่างที่ 1: User Login System - ระบบ login ผู้ใช้

**States:** Logged Out → Logging In → Logged In

```
[Logged Out]
    |
    | Event: Enter credentials
    v
[Logging In]
    |
    | Event: Credentials valid
    v
[Logged In]
    |
    | Event: Logout
    v
[Logged Out]
```

**State Transition Table:**

| Current State | Event               | Next State | Action               |
| ------------- | ------------------- | ---------- | -------------------- |
| Logged Out    | Enter credentials   | Logging In | Validate credentials |
| Logging In    | Valid credentials   | Logged In  | Create session       |
| Logging In    | Invalid credentials | Logged Out | Show error           |
| Logged In     | Logout              | Logged Out | Destroy session      |
| Logged In     | Session timeout     | Logged Out | Auto logout          |

#### 5.4 ตัวอย่างที่ 2: Library System - Book Status - สถานะของหนังสือ

**Business Rules:**

- หนังสือมี 4 สถานะ: **Available, Reserved, Borrowed, Under Maintenance**
- สถานะเปลี่ยนตาม events ที่เกิดขึ้น

**State Transition Diagram:**

```
         ┌─────────────┐
         │  Available  │ ◄────────┐
         └──────┬──────┘          │
                │                 │
        ┌───────┴────────┐        │
        │                │        │
        │ Borrow         │ Return │
        │                │        │
        v                │        │
   ┌─────────┐           │        │
   │ Borrowed│───────────┘        │
   └────┬────┘                    │
        │                         │
        │ Reserve (while borrowed)│
        v                         │
   ┌─────────┐                    │
   │ Reserved│────────────────────┘
   └────┬────┘     Cancel/Borrow
        │
        │ Mark for maintenance
        v
   ┌──────────────────┐
   │ Under Maintenance│
   └──────────────────┘
           │
           │ Repair complete
           └────────────────────> [Available]
```

**State Transition Table:**

| Current State     | Event            | Conditions          | Next State        | Action                        |
| ----------------- | ---------------- | ------------------- | ----------------- | ----------------------------- |
| Available         | Borrow           | Member eligible     | Borrowed          | Create borrow record          |
| Available         | Reserve          | -                   | Reserved          | Create reservation            |
| Available         | Mark maintenance | Admin only          | Under Maintenance | Update status                 |
| Borrowed          | Return           | -                   | Available         | Update return date            |
| Borrowed          | Report damage    | -                   | Under Maintenance | Create maintenance ticket     |
| Reserved          | Borrow           | By reserver         | Borrowed          | Convert reservation to borrow |
| Reserved          | Cancel           | By reserver/timeout | Available         | Remove reservation            |
| Under Maintenance | Repair complete  | Admin only          | Available         | Clear maintenance flag        |

#### 5.5 Test Coverage Strategies (กลยุทธ์ coverage)

**1. All States Coverage** - ทดสอบให้ผ่านทุกสถานะอย่างน้อย 1 ครั้ง

```
Test: Available → Borrowed → Available
```

**2. All Transitions Coverage (0-Switch)** - ทดสอบทุก transition อย่างน้อย 1 ครั้ง

```
TC01: Available → Borrowed
TC02: Borrowed → Available
TC03: Available → Reserved
TC04: Reserved → Borrowed
TC05: Reserved → Available (Cancel)
TC06: Available → Under Maintenance
TC07: Under Maintenance → Available
TC08: Borrowed → Under Maintenance
```

**3. All Transition Pairs Coverage (1-Switch)** - ทดสอบทุกคู่ transitions ที่ต่อกัน

```
TC09: Available → Borrowed → Available
TC10: Available → Reserved → Borrowed
TC11: Available → Reserved → Available
TC12: Borrowed → Under Maintenance → Available
```

**4. Invalid Transitions** - ทดสอบ transitions ที่ไม่ควรเกิด

```
TC13: Borrowed → Reserved (should fail)
TC14: Under Maintenance → Borrowed (should fail)
TC15: Reserved → Under Maintenance (should fail)
```

#### 5.6 Test Cases Example (JavaScript)

```javascript
describe("Book State Transitions", () => {
  let book;

  beforeEach(() => {
    book = new Book({ id: "B001", status: "Available" });
  });

  // Valid Transitions
  test("TC01: Available → Borrowed", () => {
    const result = book.borrow(memberId);
    expect(result.success).toBe(true);
    expect(book.status).toBe("Borrowed");
  });

  test("TC02: Borrowed → Available (Return)", () => {
    book.borrow(memberId);
    const result = book.return();
    expect(result.success).toBe(true);
    expect(book.status).toBe("Available");
  });

  test("TC03: Available → Reserved", () => {
    const result = book.reserve(memberId);
    expect(result.success).toBe(true);
    expect(book.status).toBe("Reserved");
  });

  test("TC04: Reserved → Borrowed (by reserver)", () => {
    book.reserve(memberId);
    const result = book.borrow(memberId);
    expect(result.success).toBe(true);
    expect(book.status).toBe("Borrowed");
  });

  // Invalid Transitions
  test("TC13: Borrowed → Reserved (should fail)", () => {
    book.borrow(member1);
    const result = book.reserve(member2);
    expect(result.success).toBe(false);
    expect(result.error).toContain("Cannot reserve borrowed book");
    expect(book.status).toBe("Borrowed"); // State unchanged
  });

  test("TC14: Under Maintenance → Borrowed (should fail)", () => {
    book.markMaintenance();
    const result = book.borrow(memberId);
    expect(result.success).toBe(false);
    expect(result.error).toContain("Book under maintenance");
    expect(book.status).toBe("Under Maintenance");
  });

  // Transition Pairs
  test("TC09: Available → Borrowed → Available", () => {
    book.borrow(memberId);
    expect(book.status).toBe("Borrowed");

    book.return();
    expect(book.status).toBe("Available");
  });

  test("TC10: Available → Reserved → Borrowed", () => {
    book.reserve(memberId);
    expect(book.status).toBe("Reserved");

    book.borrow(memberId);
    expect(book.status).toBe("Borrowed");
  });
});
```

#### 5.7 Best Practices

✅ **วาด State Diagram ก่อนเขียน test cases** (Draw diagram first)  
✅ **ระบุ transitions ที่ valid และ invalid** (Identify valid/invalid transitions)  
✅ **ทดสอบ edge cases** - timeout, concurrent access  
✅ **ทดสอบ sequence ของ transitions หลายขั้น** (Test multi-step sequences)  
✅ **Document ให้ชัดเจน** - ใช้เป็น specification

---

### 6. เลือกใช้เทคนิคให้เหมาะสม (Selecting Appropriate Techniques)

#### 6.1 Decision Guide (คู่มือการเลือก)

| Scenario                           | Best Technique       | Why?                                      |
| ---------------------------------- | -------------------- | ----------------------------------------- |
| ระบบรับ input เป็นช่วง (range)     | **BVA** + EP         | Bugs มักเกิดที่ boundaries                |
| Business rules ซับซ้อนหลายเงื่อนไข | **Decision Table**   | ครอบคลุมทุก combinations                  |
| ระบบมีการเปลี่ยนสถานะ              | **State Transition** | ทดสอบ workflow และ transitions            |
| ระบบมี input หลายประเภท            | **EP**               | แบ่งกลุ่ม input ให้ชัดเจน                 |
| ระบบมี validation rules            | **EP** + **BVA**     | ครอบคลุมทั้ง valid/invalid และ boundaries |

#### 6.2 การใช้งานร่วมกัน (Using Together)

เทคนิคเหล่านี้ **ใช้ร่วมกันได้** เพื่อความครอบคลุม:

**ตัวอย่าง:** Book Borrowing Function

- ใช้ **EP** แบ่ง member types, book types
- ใช้ **BVA** ทดสอบ borrowing limits (1-5 books)
- ใช้ **Decision Table** สำหรับ borrowing rules (overdue, limits, availability)
- ใช้ **State Transition** สำหรับ book status workflow

---

### 7. สรุปและ Key Takeaways (Summary)

#### 📋 สรุปเทคนิค (Summary of Techniques)

| Technique            | ใช้เมื่อไหร่           | จุดแข็ง                   | ข้อควรระวัง               |
| -------------------- | ---------------------- | ------------------------- | ------------------------- |
| **EP**               | มี input หลายประเภท    | ลด test cases แต่ครอบคลุม | ต้องแบ่ง partitions ให้ดี |
| **BVA**              | มี input เป็นช่วง      | หา boundary bugs ได้ดี    | ต้องใช้คู่กับ EP          |
| **Decision Table**   | Business rules ซับซ้อน | ครอบคลุมทุก combinations  | ต้องการเวลาในการสร้าง     |
| **State Transition** | ระบบมีหลายสถานะ        | ทดสอบ workflow ได้ดี      | ต้องเข้าใจ state diagram  |

#### 🎯 Best Practices ทั้งหมด (Overall Best Practices)

1. **เริ่มจากการทำความเข้าใจ requirements อย่างละเอียด** (Understand requirements first)
2. **เลือกเทคนิคที่เหมาะสมกับลักษณะของระบบ** (Select appropriate techniques)
3. **ใช้หลายเทคนิคร่วมกันเพื่อความครอบคลุม** (Use multiple techniques together)
4. **Document การออกแบบ test cases ให้ชัดเจน** (Document clearly)
5. **Review test cases กับทีมก่อนเริ่มทดสอบ** (Review with team)
6. **Update test cases เมื่อ requirements เปลี่ยน** (Update when requirements change)
