Skip to main content
skill CX Codex

testng-skill — Claude Code skill: setup and use

Generates Java TestNG tests with groups, data providers, parallel execution, suite XML, and listeners. Use it when building or organising TestNG coverage.

MIT 243 installs ★ 393 updated 2026-10-13

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add LambdaTest/agent-skills --skill testng-skill -a claude-code
Open on GitHub

What testng-skill does

This skill generates Java tests for TestNG with groups, @DataProvider, method dependencies, soft assertions, and lifecycle annotations. It can also create testng.xml with group filters, package or class selection, and parallel execution at method, class, or test level.

The material includes ITestListener examples, Maven configuration, and commands for running a suite, group, or class. Reports are read from test-output/index.html. The run commands use Maven, and the generated code targets Java with TestNG.

It is available for Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, and OpenCode. More detailed patterns are organised in reference/playbook.md, covering drivers, factories, reporting, and CI/CD.

What it helps with

  • generate Java TestNG tests with groups
  • feed cases into tests through @DataProvider
  • configure parallel execution in testng.xml
  • attach a listener for failed tests
  • run a suite, group, or class with Maven

Example prompts for the agent

  • Generate Java TestNG tests for LoginService with smoke and regression groups.
  • Create an @DataProvider for three login cases and add testng.xml to run them.
  • Set up method-level parallel execution in testng.xml and a listener that prints the failed test name.

How to install testng-skill

1Skills CLI (Vercel)

npx skills add LambdaTest/agent-skills --skill testng-skill -a claude-code

2Manually: put the files in place

~/.claude/skills/testng-skill/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/testng-skill/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about testng-skill

How do I install testng-skill in Claude Code?

Run npx skills add LambdaTest/agent-skills --skill testng-skill -a claude-code, then check ~/.claude/skills/testng-skill/SKILL.md.

What does testng-skill do?

It generates Java TestNG tests, groups, data providers, suite XML configuration, parallel execution settings, and listeners.

Which run commands does testng-skill cover?

Use mvn test -DsuiteXmlFile=testng.xml for a suite, mvn test -Dgroups=smoke for a group, or mvn test -Dtest=LoginTest for a class.

Source text

SKILL.md · MIT
---
name: testng-skill
description: >
  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".
languages:
  - Java
category: unit-testing
license: MIT
metadata:
  author: TestMu AI
  version: "1.0"
---

# TestNG Testing Skill

## Core Patterns

### Basic Test with Groups

```java
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

```java
@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

```xml
<!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

```xml
<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

```java
SoftAssert soft = new SoftAssert();
soft.assertEquals(user.getName(), "Alice");
soft.assertEquals(user.getAge(), 25);
soft.assertTrue(user.isActive());
soft.assertAll();  // Reports all failures at once
```

### Listeners

```java
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 → @AfterSuite
```

### Anti-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 |

© TestMu AI · MIT · LambdaTest/agent-skills

Similar skills

All skills for Testing and QA →

From the same set47

The whole set →
detox-skill Generates Detox E2E tests for React Native projects in JavaScript and TypeScript. Sets up tests for local emulators and TestMu AI cloud runs. CX Codex +1 252installs hyperexecute-skill This skill prepares and runs HyperExecute test jobs, checks YAML locally, connects CI, and helps investigate failed cloud runs. CX Codex +1 250installs xcuitest-skill Generates XCUITest UI tests for iOS and iPadOS apps. Detects whether to use local Xcode simulators or TestMu AI cloud devices, then builds test code accordingly. CX Codex +1 248installs puppeteer-skill Generates Puppeteer scripts for browser automation, scraping, and PDF output. Activates when you mention Puppeteer, headless Chrome, page.goto, or PDF generation. CX Codex +1 247installs codeception-skill Generates PHP Codeception acceptance, functional, and unit tests using BDD actor workflows. Useful for web interface validation and browser automation. CX Codex +1 243installs flutter-testing-skill flutter-testing-skill generates widget tests, integration tests, and golden tests for Flutter in Dart. Runs locally or on real devices via TestMu AI cloud. CX Codex +1 242installs smartui-skill This skill prepares SmartUI visual regression tests for screenshot comparison. Use it to check pages and components across browsers and viewports. CX Codex +1 237installs jasmine-skill Generates test specs in Jasmine for JavaScript and TypeScript. Includes BDD patterns, spy and mock syntax, async support — the code editor writes describe, it, expect, and spy calls automatically. CX Codex +1 237installs

Project sponsors

Companies that keep this analytics open