Automated test generation
Unit test, integration test, E2E test —— lempar code ke OpenClaw, test case auto generate
Nulis test, siapa yang ga pusing?
Feature kejar deadline, testing selalu "next release aja deh". Pas live? Wduh, edge case sama sekali ga tercakup.
Nulis mock sampe mual, satu endpoint tergantung tiga service, sekadar mock data aja setengah jam, lebih banyak dari business code.
Coverage report 30%, boss tanya dan cuma bisa bohong "core logic udah tercakup". Sebenarnya happy path aja belum lengkap.
OpenClaw bantu apa soal testing
OpenClaw bukan asal generate beberapa test case buat kamu. Dia analisis function signature, branch logic, exception handling, auto identify edge case dan exception scenario.
Function kamu ada null check? Dia generate test sama null input. Ada loop? Test empty array, single element, banyak data. Ada try-catch? Construct input yang trigger exception.
Plus dia ngerti framework testing kamu —— Jest, Pytest, JUnit, Vitest, generate code langsung bisa jalan, ga perlu manual fix format.
Prompt testing yang langsung bisa dipake
Tiga prompt cover unit test, E2E, load test. Pilih sesuai butuh.
Analisis semua exported function dan class method di module ini.
Generate unit test lengkap buat setiap function, requirement:
1. Coverage target 90% minimum (statement + branch coverage)
2. Setiap function test: normal input, boundary value, exception input
3. External dependency pake mock, jangan tergantung real DB atau network
4. Test naming clear, format "should xxx when xxx"
5. Add setup/teardown yang perlu
Pake testing framework dan assertion library existing di project, keep style konsisten.
Write E2E test sama Playwright buat login flow berikut:
Test scenario:
1. Normal login: input username/password benar, verify redirect ke homepage
2. Wrong password: input password salah, verify error message
3. Empty form submit: ga input apa-apa, verify form validation
4. Remember me: click "remember me", close, reopen, verify login state
5. Logout: login terus click exit, verify redirect ke login page
Requirement:
- Pakai Page Object Model pattern
- Add wait strategy yang reasonable, jangan pake sleep
- Screenshot gagal scenario buat debug
Generate load test script buat API endpoint berikut (k6 atau Artillery):
Test config:
1. Gradual load: mulai 10 concurrent, nambah 10 tiap 30 detik, max 200 concurrent
2. Duration: total 5 menit
3. Request distribution: 70% read, 20% write, 10% update
4. Metrics record: P50/P95/P99 latency, error rate, throughput
Generate result analysis script, output performance bottleneck report. Kalo P99 > 500ms atau error rate > 1%, mark sebagai butuh optimize.
Test generation: OpenClaw vs Copilot
Dua-duanya bisa generate test, tapi quality jauh beda.
- Analisis logic dan branch path lengkap, edge case coverage komplit
- Ngerti relasi lintas file, mock generation akurat
- Support specify coverage target, ga capai? Tambahin test case
- Generate E2E, load test, scenario kompleks dengan script lengkap
- Generate berdasar file current aja, lintas file dependency mudah ketinggalan
- Mostly generate happy path test aja, edge coverage kurang
- Mock sering butuh manual fix
- Scenario kompleks (E2E, load test) support terbatas