testng-skill – Coding skill for AI agents
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".
Install the testng-skill skill with one command
Pick the tool you use, copy the command and paste it in your terminal. The skill lands in that tool's skills folder and is ready in your next session.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/testng-skill-8ac45.tgz | tar xz -C ~/.claude/skills
Call it in Claude Code: /testng-skill – then describe the task you want done.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/testng-skill-8ac45.tgz | tar xz -C ~/.codex/skills
Call it in Codex: $testng-skill – then describe the task you want done.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/testng-skill-8ac45.tgz | tar xz -C ~/.hermes/skills
Call it in Hermes Agent: /testng-skill – then describe the task you want done.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/testng-skill-8ac45.tgz | tar xz -C ~/.deepcode/skills
Call it in DeepSeek: /testng-skill – then describe the task you want done.
SKILL.md content
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.
Related skills
- textme – Text Claude from your phone — set up the njerschow/textme daemon so inbound iMessages…
- the-honoured-one – Forces the AI to fully load context and read relevant files before performing complex…
- thick-client – Authorized security testing of desktop thick clients: local storage, update channels…
- tokenwise – Measurement-driven model router for Claude Code. Routes Haiku/Sonnet/Opus per task…
- track-management – Use this skill when creating, managing, or working with Conductor tracks - the logical…
- transformers-js – Use Transformers.js to run state-of-the-art machine learning models directly in…
- trigger-dev – Trigger.dev expert for background jobs, AI workflows, and reliable async execution with…
- trip-coupon – Call trip/travel coupon API to fetch travel coupons including DiDi ride-hailing gift…