Menggunakan AI untuk test automation: generate tests, self-healing locators, AI-powered triage, dan mengintegrasikan AI ke workflow testing

Setelah di episode 20 kita membangun test environment, pada episode ini kita membahas tren terbesar 2026: AI-assisted testing. AI membantu QA automation engineer bekerja lebih cepat dan efektif.
Prompt: "Generate Playwright E2E tests untuk halaman login
dengan email field, password field, dan login button.
Test harus cover: valid login, invalid credentials,
empty fields, dan password visibility toggle."
Output: complete test suite dengan assertions// AI bisa generate tests dari source code
// Input: component source code
// Output: test cases untuk component tersebut
// Contoh prompt:
// "Write Playwright tests untuk UserProfile component yang
// menampilkan nama, email, dan button edit"Self-Healing: test otomatis repair diri saat locator berubah
├── AI detect locator berubah
├── AI suggest alternative locators
├── Auto-repair tanpa human intervention
└── Log perubahan untuk review// Custom self-healing locator
async function findElement(page: Page, locator: string) {
// Try primary locator
let element = page.locator(locator);
if (await element.count() > 0) return element;
// AI-powered fallback
const alternatives = await getAISuggestions(locator);
for (const alt of alternatives) {
element = page.locator(alt);
if (await element.count() > 0) {
console.log(`Self-healed: ${locator} → ${alt}`);
return element;
}
}
throw new ElementNotFound(`Element not found: ${locator}`);
}// AI menilai severity test failure
async function triageFailure(failure: TestFailure) {
const aiAnalysis = await analyzeWithAI({
testName: failure.title,
error: failure.error,
screenshot: failure.screenshot,
history: failure.history,
});
return {
severity: aiAnalysis.severity,
flaky: aiAnalysis.isFlaky,
rootCause: aiAnalysis.rootCause,
suggestion: aiAnalysis.suggestion,
};
}| Tool | Fungsi |
|---|---|
| GitHub Copilot | Generate test code |
| Testim | Self-healing tests |
| Mabl | AI-powered test automation |
| Functionize | AI test generation |
| Applitools | AI visual testing |
AI Integration Best Practices:
├── Gunakan AI sebagai asisten, bukan replacement
├── Review AI-generated tests sebelum commit
├── Monitor self-healing actions
├── Track AI accuracy dan false positive rate
├── Human judgment untuk edge cases
└── Continuous improvement dari feedbackTip
Mulai dengan Copilot untuk generate test boilerplate. Setelah itu, evaluasi self-healing tools untuk flaky tests.
# 1. Gunakan Copilot untuk generate test
# Prompt di VS Code: "Generate Playwright test for login page"
# 2. Review dan refine generated code
# 3. Jalankan test
npx playwright test login.spec.ts
# 4. Monitor results dan refineDi episode 22 selanjutnya kita akan membahas agentic AI testing — AI agents untuk eksplorasi dan verifikasi otomatis. Sampai jumpa di episode 22!