Back to Skills

testng-data-driven

verified

Use when implementing data-driven tests with TestNG DataProviders, factory methods, and parameterization patterns.

View on GitHub

Marketplace

han

TheBushidoCollective/han

Plugin

jutsu-testng

Technique

Repository

TheBushidoCollective/han
60stars

jutsu/jutsu-testng/skills/testng-data-driven/SKILL.md

Last Verified

January 24, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/TheBushidoCollective/han/blob/main/jutsu/jutsu-testng/skills/testng-data-driven/SKILL.md -a claude-code --skill testng-data-driven

Installation paths:

Claude
.claude/skills/testng-data-driven/
Powered by add-skill CLI

Instructions

# TestNG Data-Driven Testing

Master TestNG data-driven testing including DataProviders, Factory patterns, and parameterization for comprehensive test coverage. This skill covers techniques for testing with multiple data sets efficiently.

## Overview

Data-driven testing separates test logic from test data, enabling a single test method to run against multiple inputs. TestNG provides powerful features for data-driven testing through DataProviders, Factory methods, and XML parameterization.

## DataProvider Basics

### Simple DataProvider

```java
import org.testng.annotations.*;
import static org.testng.Assert.*;

public class SimpleDataProviderTest {

    @DataProvider(name = "numbers")
    public Object[][] provideNumbers() {
        return new Object[][] {
            {1, 2, 3},
            {4, 5, 9},
            {0, 0, 0},
            {-1, 1, 0}
        };
    }

    @Test(dataProvider = "numbers")
    public void testAddition(int a, int b, int expected) {
        assertEquals(a + b, expected);
    }
}
```

### DataProvider with Single Values

```java
public class SingleValueDataProviderTest {

    @DataProvider(name = "validEmails")
    public Object[][] provideValidEmails() {
        return new Object[][] {
            {"user@example.com"},
            {"test.user@domain.org"},
            {"admin+tag@company.co.uk"},
            {"user123@test.io"}
        };
    }

    @Test(dataProvider = "validEmails")
    public void testValidEmail(String email) {
        assertTrue(isValidEmail(email), "Email should be valid: " + email);
    }

    private boolean isValidEmail(String email) {
        return email != null && email.matches("^[\\w+.-]+@[\\w.-]+\\.[a-zA-Z]{2,}$");
    }
}
```

## Advanced DataProvider Patterns

### DataProvider in Separate Class

```java
// DataProviders class
public class TestDataProviders {

    @DataProvider(name = "userData")
    public static Object[][] provideUserData() {
        return new Object[][] {
            {"john", "john@exam

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
14050 chars