Token导航 LogoToken导航

Agent Skill · 待分类

testng-fundamentals(测试基础知识)

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

testng-fundamentals 是待分类类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为操作浏览器;许可证为 MIT,第三方扫描已通过,按安装量在待分类类的 11,209 个 Skill 里排第 4,973。

总安装 636周安装 26GitHub Stars 142下载 206核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
MIT

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:testng-fundamentals(测试基础知识)
来源仓库:https://github.com/thebushidocollective/han
仓库路径:skills/testng-fundamentals
安装命令:
npx skills add https://github.com/thebushidocollective/han --skill testng-fundamentals
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/thebushidocollective/han --skill testng-fundamentals

这个 Skill 是做什么的

这个 Skill 的分类还没最终确定,用法以来源仓库的说明为准。

用于辅助测试设计、自动化测试、用例整理和回归验证。适合编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需确认项目测试框架、运行命令和夹具数据,避免误改真实逻辑。涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。建议结合原始 README 进一步核验具体用法和限制条件。

来源仓库内路径:skills/testng-fundamentals

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/thebushidocollective/han --skill testng-fundam…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要操作浏览器,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

testng-fundamentals 怎么安装?

在终端执行 npx skills add https://github.com/thebushidocollective/han --skill testng-fundamentals。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

testng-fundamentals 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

testng-fundamentals 需要什么权限?

权限级别是操作浏览器。该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

testng-fundamentals 是免费的吗?

来源标注的许可证是 MIT。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

testng-fundamentals 用的人多吗?

公开数据是累计安装 636 次,近一周安装 26 次,下载 206 次,GitHub 142 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

testng-fundamentals 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 3 个目录同时收录,说明这个 Skill 流传比较广。
  • 许可证明确为 MIT,商用和分发边界好判断。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理待分类类任务、又不想每次都手写提示词的人。
  • 需要许可证清楚、并且有第三方扫描结果的团队项目。

不太适合

  • 需要厂商级技术支持和 SLA 的生产系统。

待分类类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
infsh-cli

infsh CLI · Codex、Claude

4,374,576382权限未标注未明确未收录
ai-video-generation

AI 视频生成 · Codex、Claude

4,313,376382调用外部服务未明确有提醒
lark-openapi-explorer

云雀 OpenAPI 浏览器 · Codex、Claude

2,064,1209,011需要联网未明确有提醒
lark-workflow-standup-report

Lark 工作流程站立报告 · Codex、Claude

2,041,6328,978需要联网未明确通过
use-my-browser

使用我的浏览器 · Codex、Claude

1,848,49140操作浏览器未明确未通过
testng-fundamentals

测试基础知识 · 本页

636142操作浏览器MIT通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

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);

        // Null checks
        Assert.assertNull(null);
        Assert.assertNotNull("value");

        // Same reference
        String s1 = "test";
        String s2 = s1;
        Assert.assertSame(s1, s2);
        Assert.assertNotSame(new String("test"), new String("test"));
    }

    @Test
    public void testAssertionsWithMessages() {
        // Assertions with custom failure messages
        Assert.assertEquals(5, 5, "Values should be equal");
        Assert.assertTrue(true, "Condition should be true");
        Assert.assertNotNull("value", "Value should not be null");
    }

    @Test
    public void testCollectionAssertions() {
        // Array assertions
        String[] expected = {"a", "b", "c"};
        String[] actual = {"a", "b", "c"};
        Assert.assertEquals(actual, expected);

        // Unordered comparison
        String[] array1 = {"a", "b", "c"};
        String[] array2 = {"c", "a", "b"};
        Assert.assertEqualsNoOrder(array1, array2);
    }
}

Soft Assertions

Soft assertions allow multiple assertions to be collected before failing:

import org.testng.annotations.Test;
import org.testng.asserts.SoftAssert;

public class SoftAssertExample {

    @Test
    public void testWithSoftAssert() {
        SoftAssert softAssert = new SoftAssert();

        // All assertions are executed
        softAssert.assertEquals(1, 1, "First check");
        softAssert.assertEquals(2, 3, "Second check - will fail");
        softAssert.assertTrue(false, "Third check - will fail");
        softAssert.assertNotNull(null, "Fourth check - will fail");

        // Report all failures at the end
        softAssert.assertAll();
    }
}

TestNG XML Configuration

Basic testng.xml Structure

<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="My Test Suite" verbose="1">

    <test name="Unit Tests">
        <classes>
            <class name="com.example.tests.UserServiceTest"/>
            <class name="com.example.tests.ProductServiceTest"/>
        </classes>
    </test>

    <test name="Integration Tests">
        <packages>
            <package name="com.example.integration.*"/>
        </packages>
    </test>

</suite>

Group Configuration

<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="Group Suite">

    <test name="Smoke Tests">
        <groups>
            <run>
                <include name="smoke"/>
            </run>
        </groups>
        <packages>
            <package name="com.example.tests.*"/>
        </packages>
    </test>

    <test name="Regression Tests">
        <groups>
            <run>
                <include name="regression"/>
                <exclude name="broken"/>
            </run>
        </groups>
        <packages>
            <package name="com.example.tests.*"/>
        </packages>
    </test>

</suite>

Parameters in testng.xml

<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="Parameterized Suite">

    <parameter name="browser" value="chrome"/>
    <parameter name="environment" value="staging"/>

    <test name="Chrome Tests">
        <parameter name="browser" value="chrome"/>
        <classes>
            <class name="com.example.tests.BrowserTest"/>
        </classes>
    </test>

    <test name="Firefox Tests">
        <parameter name="browser" value="firefox"/>
        <classes>
            <class name="com.example.tests.BrowserTest"/>
        </classes>
    </test>

</suite>

Using parameters in tests:

import org.testng.annotations.*;

public class BrowserTest {

    @Parameters({"browser", "environment"})
    @BeforeClass
    public void setUp(String browser, @Optional("production") String env) {
        System.out.println("Browser: " + browser);
        System.out.println("Environment: " + env);
    }

    @Test
    public void testBrowser() {
        // Test implementation
    }
}

Test Groups

Defining and Using Groups

public class GroupExample {

    @BeforeGroups("database")
    public void setUpDatabase() {
        System.out.println("Setting up database");
    }

    @AfterGroups("database")
    public void tearDownDatabase() {
        System.out.println("Tearing down database");
    }

    @Test(groups = {"smoke", "frontend"})
    public void testHomePage() {
        System.out.println("Testing home page");
    }

    @Test(groups = {"smoke", "api"})
    public void testHealthEndpoint() {
        System.out.println("Testing health endpoint");
    }

    @Test(groups = {"regression", "database"})
    public void testDataPersistence() {
        System.out.println("Testing data persistence");
    }

    @Test(groups = {"slow", "integration"})
    public void testEndToEnd() {
        System.out.println("Testing end-to-end flow");
    }
}

Group Dependencies

public class GroupDependencyExample {

    @Test(groups = {"init"})
    public void initializeSystem() {
        System.out.println("Initializing");
    }

    @Test(groups = {"init"})
    public void configureSystem() {
        System.out.println("Configuring");
    }

    @Test(dependsOnGroups = {"init"}, groups = {"core"})
    public void coreTest1() {
        System.out.println("Core test 1");
    }

    @Test(dependsOnGroups = {"init"}, groups = {"core"})
    public void coreTest2() {
        System.out.println("Core test 2");
    }

    @Test(dependsOnGroups = {"core"}, groups = {"final"})
    public void finalTest() {
        System.out.println("Final test");
    }
}

Listeners

ITestListener

import org.testng.*;

public class TestListener implements ITestListener {

    @Override
    public void onTestStart(ITestResult result) {
        System.out.println("Starting: " + result.getName());
    }

    @Override
    public void onTestSuccess(ITestResult result) {
        System.out.println("Passed: " + result.getName());
    }

    @Override
    public void onTestFailure(ITestResult result) {
        System.out.println("Failed: " + result.getName());
        System.out.println("Reason: " + result.getThrowable().getMessage());
    }

    @Override
    public void onTestSkipped(ITestResult result) {
        System.out.println("Skipped: " + result.getName());
    }

    @Override
    public void onStart(ITestContext context) {
        System.out.println("Test suite starting: " + context.getName());
    }

    @Override
    public void onFinish(ITestContext context) {
        System.out.println("Test suite finished: " + context.getName());
    }
}

Using Listeners

// Using annotation
@Listeners(TestListener.class)
public class MyTest {
    @Test
    public void testMethod() {
        // Test implementation
    }
}

Or in testng.xml:

<suite name="Suite">
    <listeners>
        <listener class-name="com.example.listeners.TestListener"/>
    </listeners>
    <test name="Test">
        <classes>
            <class name="com.example.tests.MyTest"/>
        </classes>
    </test>
</suite>

Best Practices

  1. Use descriptive test names - Name tests clearly to indicate what they verify
  2. Group related tests - Use groups to organize tests by feature or type
  3. Avoid test dependencies - Tests should be independent when possible
  4. Use soft assertions wisely - For multiple related checks in one test
  5. Configure timeouts - Prevent tests from hanging indefinitely
  6. Use BeforeClass/AfterClass - For expensive setup/teardown operations
  7. Leverage testng.xml - For suite-level configuration and organization
  8. Implement listeners - For custom reporting and test lifecycle hooks
  9. Use priority sparingly - Prefer dependency declarations over priority
  10. Document test purpose - Use the description attribute

Common Pitfalls

  1. Test order dependency - Relying on implicit test execution order
  2. Shared mutable state - Tests modifying shared resources
  3. Missing assertions - Tests without verification
  4. Overly broad groups - Groups that are too generic to be useful
  5. Circular dependencies - Tests that depend on each other in a cycle
  6. Long-running tests - Tests without appropriate timeouts
  7. Poor failure messages - Assertions without descriptive messages
  8. Ignoring test failures - Using enabled=false to hide failing tests
  9. Hard-coded test data - Not using parameters or data providers
  10. Missing cleanup - Not properly releasing resources in @After methods

When to Use This Skill

  • Setting up TestNG in new Java projects
  • Writing unit and integration tests with TestNG
  • Configuring test suites with testng.xml
  • Organizing tests with groups and dependencies
  • Implementing custom test listeners
  • Troubleshooting TestNG test failures
  • Migrating from JUnit to TestNG
  • Training team members on TestNG fundamentals

平台分布

OpenCode

29.35%
按下载量换算60

Codex

21.79%
按下载量换算45

Claude Code

18.39%
按下载量换算38

windsurf

12.68%
按下载量换算26

trae

7.8%
按下载量换算16

Antigravity

3.45%
按下载量换算7

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

继续浏览同类 Skills