testng-skill – skill Lập trình cho agent AI
Tạo test TestNG bằng Java với group, data provider, thực thi song song, cấu hình suite XML và listener. Dùng khi người dùng nhắc đến \"TestNG\", \"@DataProvider\", \"testng.xml\", \"groups\". Kích hoạt khi: \"TestNG\", \"@DataProvider\", \"testng.xml\", \"TestNG suite\", \"parallel tests Java\".
Cài skill testng-skill bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/testng-skill-8ac45.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /testng-skill – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/testng-skill-8ac45.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $testng-skill – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/testng-skill-8ac45.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /testng-skill – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/testng-skill-8ac45.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /testng-skill – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
TestNG Testing Skill
When to Use
Use this skill when you need generates TestNG tests in Java with groups, data providers, parallel execution, XML suite configuration, and listeners. Use when user mentions "TestNG", "@DataProvider", "testng.xml", "groups". Triggers on: "TestNG", "@DataProvider", "testng.xml", "TestNG suite", "parallel tests Java".
Examples are separate fragments: supply loginService/dashboard and the project AuthenticationException, import org.testng.asserts.SoftAssert and listener interfaces as needed. The three parallel suite lines are alternatives, not one valid XML document. Maven suite-property/report locations depend on the actual Surefire configuration; inspect pom.xml rather than assuming these commands configure it. Isolate test users/data and per-thread browser/service state before parallel execution, and close only resources created by the test. The listed reference/playbook.md is absent from this catalog copy.
Core Patterns
Basic Test with Groups
package tests;
import org.testng.annotations.*;
import org.testng.Assert;
public class LoginTest {
@BeforeMethod
public void setUp() { /* setup */ }
@Test(groups = "smoke")
public void testLoginSuccess() {
Assert.assertTrue(loginService.login("[email protected]", "password123"));
}
@Test(groups = "regression", dependsOnMethods = "testLoginSuccess")
public void testAccessDashboard() {
Assert.assertNotNull(dashboard.getContent());
}
@Test(expectedExceptions = AuthenticationException.class)
public void testLoginInvalidPassword() {
loginService.login("[email protected]", "wrong");
}
@AfterMethod
public void tearDown() { /* cleanup */ }
}Data Providers
@DataProvider(name = "loginData")
public Object[][] loginData() {
return new Object[][] {
{"[email protected]", "admin123", true},
{"[email protected]", "password", true},
{"[email protected]", "wrong", false},
};
}
@Test(dataProvider = "loginData")
public void testLogin(String email, String password, boolean expected) {
Assert.assertEquals(loginService.login(email, password), expected);
}TestNG XML Suite
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="Regression" parallel="tests" thread-count="5">
<test name="Smoke">
<groups><run><include name="smoke"/></run></groups>
<classes><class name="tests.LoginTest"/></classes>
</test>
<test name="Full">
<groups><run><include name="regression"/><exclude name="flaky"/></run></groups>
<packages><package name="tests.*"/></packages>
</test>
</suite>Parallel Execution
<suite parallel="methods" thread-count="5"> <!-- Method level -->
<suite parallel="classes" thread-count="5"> <!-- Class level -->
<suite parallel="tests" thread-count="5"> <!-- Test level -->Soft Assertions
SoftAssert soft = new SoftAssert();
soft.assertEquals(user.getName(), "Alice");
soft.assertEquals(user.getAge(), 25);
soft.assertTrue(user.isActive());
soft.assertAll(); // Reports all failures at onceListeners
public class TestListener implements ITestListener {
@Override public void onTestFailure(ITestResult result) {
System.out.println("Failed: " + result.getName());
// Take screenshot, log, etc.
}
}
@Listeners(TestListener.class)
public class LoginTest { /* ... */ }Lifecycle Annotations
@BeforeSuite → @BeforeTest → @BeforeClass → @BeforeMethod → @Test → @AfterMethod → @AfterClass → @AfterTest → @AfterSuiteAnti-Patterns
| Bad | Good | Why |
|-----|------|-----|
| dependsOnMethods everywhere | Independent tests | Cascading failures |
| No groups | @Test(groups = "smoke") | Can't run subsets |
| Hard-coded test data | @DataProvider | Reusable |
| Priority ordering | Independent tests | Fragile |
Quick Reference
| Task | Command |
|------|---------|
| Run suite | mvn test -DsuiteXmlFile=testng.xml |
| Run group | mvn test -Dgroups=smoke |
| Run class | mvn test -Dtest=LoginTest |
| Reports | test-output/index.html |
Deep Patterns → reference/playbook.md
| § | Section | Lines |
|---|---------|-------|
| 1 | Project Setup & Configuration | Maven + Surefire config |
| 2 | Suite XML Configuration | Multi-env, parallel, groups |
| 3 | BaseTest & Thread-Safe Driver | ThreadLocal, ConfigReader |
| 4 | Data Providers (Advanced) | Excel, JSON, CSV, parallel, cross-class |
| 5 | Factory Pattern | Cross-browser matrix |
| 6 | Listeners (Production Suite) | Retry, screenshot, timing |
| 7 | Soft Assertions & Dependencies | Groups, method deps |
| 8 | Page Object Integration | PageFactory, fluent POs |
| 9 | Parallel Execution Strategies | Method/class/test/mixed |
| 10 | Reporting Integration | Allure, ExtentReports |
| 11 | CI/CD Integration | GitHub Actions, Jenkins |
| 12 | Debugging Quick-Reference | 12 common problems |
| 13 | Best Practices Checklist | 14 items |
Limitations
- Use this skill only when the task clearly matches its upstream source and local project context.
- Verify commands, generated code, dependencies, credentials, and external service behavior before applying changes.
- Do not treat examples as a substitute for environment-specific tests, security review, or user approval for destructive or costly actions.
Skill liên quan
- textme – Nhắn tin cho Claude từ điện thoại — thiết lập daemon njerschow/textme để iMessage đến…
- the-honoured-one – Buộc AI tải đầy đủ ngữ cảnh và đọc các file liên quan trước khi thực hiện tác vụ phức…
- thick-client – Kiểm thử bảo mật được ủy quyền cho ứng dụng desktop thick client: lưu trữ cục bộ, kênh…
- tokenwise – Bộ định tuyến model theo số đo cho Claude Code. Phân tuyến Haiku/Sonnet/Opus theo loại…
- track-management – Dùng skill này khi tạo, quản lý hoặc làm việc với track Conductor, là các đơn vị công…
- transformers-js – Dùng Transformers.js để chạy trực tiếp các mô hình machine learning hiện đại trong…
- trigger-dev – Chuyên gia Trigger.dev cho background job, workflow AI và thực thi bất đồng bộ đáng tin…
- trip-coupon – Gọi API phiếu giảm giá du lịch để lấy phiếu, gồm gói quà đi xe DiDi và gói phiếu khách…