Saltar al contenido
Skillpedia
Pruebas48 mil · #5975

testng-skill

Qué hace

Esta herramienta te ayuda a crear pruebas automáticas para programas en Java usando la biblioteca TestNG. Permite organizar las pruebas en grupos, usar datos variados y configurar la ejecución en paralelo.

Cuándo usarla

  • ✓Necesito crear pruebas para una aplicación en Java.
  • ✓Quiero organizar mis pruebas en categorías (grupos).
  • ✓Necesito probar la misma función con distintos datos de entrada.

Link de la skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/testng-skill/SKILL.md

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/testng-skill/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“Crea una prueba en Java con TestNG para verificar el inicio de sesión de usuarios, con los grupos 'smoke' y 'regression'.”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

La herramienta usa anotaciones especiales en el código Java (como @Test y @DataProvider) y archivos de configuración XML para definir cómo se ejecutan las pruebas y cómo se organizan.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de GitHub.

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".

Core Patterns

Basic Test with Groups

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("user@test.com", "password123"));
    }

    @Test(groups = "regression", dependsOnMethods = "testLoginSuccess")
    public void testAccessDashboard() {
        Assert.assertNotNull(dashboard.getContent());
    }

    @Test(expectedExceptions = AuthenticationException.class)
    public void testLoginInvalidPassword() {
        loginService.login("user@test.com", "wrong");
    }

    @AfterMethod
    public void tearDown() { /* cleanup */ }
}

Data Providers

@DataProvider(name = "loginData")
public Object[][] loginData() {
    return new Object[][] {
        {"admin@test.com", "admin123", true},
        {"user@test.com", "password", true},
        {"invalid@test.com", "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 once

Listeners

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

Limitations

…

Preguntas frecuentes

¿Qué son los 'grupos' de pruebas?

Los grupos son como categorías que puedes asignar a tus pruebas. Por ejemplo, puedes tener un grupo 'smoke' para pruebas rápidas y esenciales, y un grupo 'regression' para pruebas más completas.

¿Qué es un 'data provider'?

Es una forma de proporcionar distintos conjuntos de datos a una misma prueba. Así no tienes que repetir el código de la prueba para cada valor que quieras comprobar.

¿Qué significa 'ejecución en paralelo'?

Significa que varias pruebas se pueden ejecutar al mismo tiempo, lo que puede acelerar el proceso de prueba, sobre todo en proyectos grandes.

Detalles

Descripción original del autor

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".

repo: sickn33/agentic-awesome-skills

Popularidad

Estrellas en GitHub
48 mil
Posición en el ranking
#5975
Licencia
MIT
Actualizada
15/10/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas