testng-fundamentals
БесплатноБез исполняемых скриптовНе проверенUse when working with TestNG annotations, assertions, test lifecycle, and configuration for Java testing.
от TheBushidoCollective★ 202 звезды на GitHubОб этом скилле
TestNG Fundamentals
Master TestNG fundamentals including annotations, assertions, test lifecycle, and XML configuration for Java testing. This skill provides comprehensive coverage of essential concepts, patterns, and best practices for professional TestNG development.
Overview
TestNG is a powerful testing framework for Java inspired by JUnit and NUnit, designed to cover a wider range of test categories: unit, functional, end-to-end, and integration testing. It supports annotations, data-driven testing, parameterization, and parallel execution.
Installation and Setup
Maven Configuration
Add TestNG to your Maven project:
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.9.0</version>
<scope>test</scope>
</dependency>
Configure the Surefire plugin for TestNG:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
Gradle Configuration
Add TestNG to your Gradle project:
dependencies {
testImplementation 'org.testng:testng:7.9.0'
}
test {
useTestNG()
}
Core Annotations
Test Lifecycle Annotations
TestNG provides comprehensive lifecycle annotations:
import org.testng.annotations.*;
public class LifecycleTest {
@BeforeSuite
public void beforeSuite() {
// Runs once before the entire test suite
System.out.println("Before Suite");
}
@AfterSuite
public void afterSuite() {
// Runs once after the entire test suite
System.out.println("After Suite");
}
@BeforeTest
public void beforeTest() {
// Runs before each <test> tag in testng.xml
System.out.println("Before Test");
}
@AfterTest
public void afterTest() {
// Runs after each <test> tag in testng.xml
System.out.println("After Test");
}
@BeforeClass
public void beforeClass() {
// Runs once before the first test method in the class
System.out.println("Before Class");
}
@AfterClass
public void afterClass() {
// Runs once after the last test method in the class
System.out.println("After Class");
}
@BeforeMethod
public void beforeMethod() {
// Runs before each test method
System.out.println("Before Method");
}
@AfterMethod
public void afterMethod() {
// Runs after each test method
System.out.println("After Method");
}
@Test
public void testMethod() {
System.out.println("Test Method");
}
}
Test Annotation Attributes
The @Test annotation supports various attributes:
public class TestAttributesExample {
@Test(description = "Verifies user login functionality")
public void testLogin() {
// Test with description
}
@Test(enabled = false)
public void disabledTest() {
// This test will not run
}
@Test(priority = 1)
public void firstTest() {
// Runs first (lower priority = earlier execution)
}
@Test(priority = 2)
public void secondTest() {
// Runs second
}
@Test(groups = {"smoke", "regression"})
public void groupedTest() {
// Test belongs to multiple groups
}
@Test(dependsOnMethods = {"testLogin"})
public void testDashboard() {
// Runs only if testLogin passes
}
@Test(dependsOnGroups = {"setup"})
public void dependentTest() {
// Runs only if all tests in "setup" group pass
}
@Test(timeOut = 5000)
public void timedTest() {
// Fails if takes more than 5 seconds
}
@Test(invocationCount = 3)
public void repeatedTest() {
// Runs 3 times
}
@Test(invocationCount = 100, threadPoolSize = 10)
public void parallelRepeatedTest() {
// Runs 100 times across 10 threads
}
@Test(expectedExceptions = IllegalArgumentException.class)
public void exceptionTest() {
throw new IllegalArgumentException("Expected");
}
@Test(expectedExceptions = RuntimeException.class,
expectedExceptionsMessageRegExp = ".*invalid.*")
public void exceptionWithMessageTest() {
throw new RuntimeException("This is invalid input");
}
}
Assertions
Basic Assertions
TestNG provides comprehensive assertion methods:
import org.testng.Assert;
import org.testng.annotations.Test;
public class AssertionExamples {
@Test
public void testBasicAssertions() {
// Equality
Assert.assertEquals(5, 5);
Assert.assertEquals("hello", "hello");
Assert.assertEquals(new int[]{1, 2, 3}, new int[]{1, 2, 3});
// Boolean
Assert.assertTrue(true);
Assert.assertFalse(false);
Установить testng-fundamentals в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadWriteEditBashGlobGrepFAQ
Что делает скилл testng-fundamentals?
Use when working with TestNG annotations, assertions, test lifecycle, and configuration for Java testing.
Как установить скилл testng-fundamentals?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл testng-fundamentals запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic