Use when implementing data-driven tests with TestNG DataProviders, factory methods, and parameterization patterns.
View on GitHubTheBushidoCollective/han
jutsu-testng
January 24, 2026
Select agents to install to:
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-drivenInstallation paths:
.claude/skills/testng-data-driven/# 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