# 10. Strategi Testing

## Level Testing

| Level | Alat | Scope |
|-------|------|--------|
| Unit | PHPUnit/Pest | Service method, helper, value object (tanpa DB/HTTP). |
| Feature | PHPUnit/Pest + Laravel | Request → response; pakai DB (RefreshDatabase). |
| E2E (opsional) | Laravel Dusk / Playwright | Browser flow (login → buat order → bayar). |
| Performance (opsional) | k6 / Apache Bench | Load API critical path. |

## Prioritas

- **Wajib:** Feature test untuk API critical: create order, update status, payment, auth.
- **Wajib:** Unit test untuk logic rumit (hitung diskon, split bill, loyalty points).
- **Nice to have:** E2E untuk flow utama (POS, checkout); performance untuk report & list besar.

## Konvensi

- Test class: `*Test` atau `*Test.php` (Pest: describe + it).
- Feature test: satu file per controller atau per use case (e.g. `OrderCreationTest`).
- Seed minimal (atau factory); jangan depend on seed lengkap.
- Mock external API (payment gateway, delivery) di test.

## CI

- Setiap push/PR: jalankan `php artisan test` (unit + feature).
- Coverage: target minimal 70% untuk path critical (Order, Payment, Auth).
