Token导航 LogoToken导航TokenDH.com
前端设计需要联网github未标认证来源可访问许可证需确认审计通过

test-harness测试工具

Agent Skill

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

总安装

367

周安装

15

GitHub Stars

218

下载量

118
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/mathews-tom/praxis-skills --skill test-harness

简介

用于辅助测试设计、自动化测试、用例整理和回归验证。

  • 适合编写单元测试、端到端测试或根据日志定位问题。
  • 需确认项目测试框架、运行命令和夹具数据后使用。test-harness 属于前端设计类 Skill,可作为该场景下的辅助能力补充。
  • 涉及浏览器或外部服务时应区分模拟环境与生产环境。
  • 安装方式:通过 npx 从指定 GitHub 仓库添加。

SKILL.md

Test Harness

Systematic test suite generation that transforms source code into comprehensive, runnable pytest files. Analyzes function signatures, dependency graphs, and complexity hotspots to produce tests covering happy paths, boundary conditions, error states, and async flows — with properly scoped fixtures and focused mocks.

Reference Files

FileContentsLoad When
references/pytest-patterns.mdFixture scopes, parametrize, marks, conftest layout, built-in fixturesAlways
references/mock-strategies.mdMock decision tree, patch boundaries, assertions, anti-patternsTarget has external dependencies
references/async-testing.mdpytest-asyncio modes, event loop fixtures, async mockingTarget contains async code
references/fixture-design.mdFactory fixtures, yield teardown, scope selection, compositionTest requires non-trivial setup
references/coverage-targets.mdThreshold table, branch vs line, pytest-cov config, exclusion patternsCoverage assessment requested

Prerequisites

  • pytest >= 7.0
  • Python >= 3.10
  • pytest-asyncio — required only when generating async tests
  • pytest-mock — optional, provides mocker fixture as alternative to unittest.mock

Workflow

Phase 1: Reconnaissance

Before writing a single test, build a model of the target code:

  1. Identify scope — What functions, classes, or modules need tests? If unspecified, check for recent modifications: git diff --name-only HEAD~5
  2. Read function signatures — Parameters, types, return types, defaults. Every parameter is a test dimension.
  3. Map dependencies — Which calls go to external systems (DB, API, filesystem, clock)? These are mock candidates.
  4. Detect complexity hotspots — Functions with high branch counts, deep nesting, or multiple return paths need more test cases.
  5. Check existing tests — If tests already exist, understand what they cover. Do not duplicate; extend.
  6. Read project conventions — Check CLAUDE.md, conftest.py, pytest.ini/pyproject.toml for fixtures, markers, and test organization patterns already in use.

Phase 2: Test Case Enumeration

For each function under test, enumerate cases across four categories:

CategoryWhat to TestExample
Happy pathExpected inputs produce expected outputsadd(2, 3) returns 5
BoundaryEdge values at limits of valid inputEmpty string, zero, max int, single element
ErrorInvalid inputs trigger proper exceptionsNone where str expected, negative index
StateState transitions produce correct side effectsObject moves from pending to active

For each case, note:

  • Input values (concrete, not abstract)
  • Expected output or exception
  • Required setup (fixtures)
  • Required mocks (external calls to suppress)

Parametrize cases that share the same test logic but differ only in input/output values.

Phase 3: Fixture Design

  1. Identify shared setup — If 3+ tests need the same object, extract a fixture.
  2. Select scope — Use the narrowest scope that avoids redundant setup: Scope Use When Example function Default. Each test gets fresh state Most unit tests class Tests within a class share expensive setup DB connection per test class module All tests in a file share setup Loaded config file session Entire test run shares setup Docker container startup
  3. Design teardown — Use yield fixtures when cleanup is needed. Never leave side effects (temp files, DB rows, monkey-patches) after a test.
  4. Identify conftest candidates — Fixtures used across multiple test files belong in conftest.py. Fixtures used in one file stay in that file.

Phase 4: Mock Strategy

  1. Decide what to mock — Mock external dependencies only:

- Network calls (API, database, message queues) - Filesystem operations (when testing logic, not I/O) - Time-dependent behavior (datetime.now, time.sleep) - Random/non-deterministic behavior

  1. Decide what NOT to mock — Never mock:

- The function under test - Pure functions called by the target (test them through the target) - Data structures and value objects

  1. Choose mock level — Patch at the import boundary of the module under test, not at the definition site. @patch('mymodule.requests.get'), not @patch('requests.get').
  2. Add mock assertions — Every mock should assert it was called with expected arguments and the expected number of times. Mocks without assertions are coverage holes.

Phase 5: Output

Generate the test file following this structure:

  1. Imports (pytest, mocks, target module)
  2. Constants and test data
  3. Fixtures (ordered by scope: session > module > class > function)
  4. Test classes or functions grouped by target function
  5. Parametrized tests where applicable

Output Format

# tests/test_{module}.py

import pytest
from unittest.mock import Mock, patch, MagicMock

from {module} import {target_function, TargetClass}

# ============================================================
# Fixtures
# ============================================================

@pytest.fixture
def valid_input():
    """Standard valid input for happy path tests."""
    return {concrete values}

@pytest.fixture
def mock_database():
    """Mock database connection."""
    with patch("{module}.db_connection") as mock_db:
        mock_db.query.return_value = [{expected data}]
        yield mock_db

# ============================================================
# {target_function} Tests
# ============================================================

class TestTargetFunction:
    """Tests for {target_function}."""

    def test_happy_path(self, valid_input):
        """Returns expected result for valid input."""
        result = target_function(valid_input)
        assert result == {expected}

    @pytest.mark.parametrize(
        "input_val, expected",
        [
            ({boundary_1}, {expected_1}),
            ({boundary_2}, {expected_2}),
            ({boundary_3}, {expected_3}),
        ],
        ids=["empty", "single", "maximum"],
    )
    def test_boundary_conditions(self, input_val, expected):
        """Handles boundary inputs correctly."""
        assert target_function(input_val) == expected

    def test_invalid_input_raises(self):
        """Raises TypeError for invalid input."""
        with pytest.raises(TypeError, match="expected str"):
            target_function(None)

    def test_external_call(self, mock_database):
        """Calls database with correct query."""
        target_function("lookup_key")
        mock_database.query.assert_called_once_with("SELECT * FROM t WHERE key = %s", ("lookup_key",))

Configuring Scope

ModeScopeDepthWhen to Use
quickSingle functionHappy path + 1 error caseRapid iteration, TDD red-green cycle
standardFile or classHappy + boundary + error + mocksDefault for most requests
comprehensiveModule or packageAll categories + async + parametrized matrixPre-release, critical path code

Calibration Rules

  1. Test isolation is non-negotiable. Every test must pass when run alone and in any order. No test may depend on the side effects of another test.
  2. Mock discipline. Mock external dependencies, not internal logic. Over-mocking produces tests that pass when the code is broken. Under-mocking produces tests that fail when the network is down.
  3. Concrete over abstract. Test data must be concrete values, not placeholders. "alice@example.com" not "test_email". 42 not "some_number". Concrete values catch type mismatches that abstract placeholders mask.
  4. One assertion focus per test. A test should verify one behavior. Multiple assertions are acceptable when they verify different aspects of the same behavior (e.g., return value AND side effect), but not when they verify unrelated behaviors.
  5. Parametrize, don't duplicate. If two tests differ only in input/output values, combine them with @pytest.mark.parametrize. Use ids for readable test names.
  6. Match project conventions. If the project uses conftest.py fixtures, class-based tests, or specific markers, follow those patterns. Do not introduce a conflicting test style.

Error Handling

ProblemResolution
Target function has no type hintsInfer types from usage patterns, default values, and docstrings. Note uncertainty in test docstring.
Target has deeply nested dependenciesMock at the nearest boundary to the function under test. Do not mock transitive dependencies individually.
No existing test infrastructure (no conftest, no pytest config)Generate a minimal conftest.py alongside the test file. Note the addition in output.
Target code is untestable (global state, hidden dependencies)Flag the design issue in the output. Generate tests for what is testable. Suggest refactoring to improve testability.
Async code detected but pytest-asyncio not installedNote the dependency requirement. Generate async test stubs with @pytest.mark.asyncio and instruct user to install.
Target module cannot be importedReport the import error. Do not generate tests for unimportable code.

When NOT to Generate Tests

Push back if:

  • The code is auto-generated (protobuf, OpenAPI client, ORM models) — test the generator or the schema, not the output
  • The request is for UI/E2E tests — this skill generates unit and integration tests only
  • The code has no clear behavior to test (pure configuration, constant definitions)
  • The user wants tests for third-party library code — test your usage of the library, not the library itself

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.06%
按下载量换算40

Claude

27.31%
按下载量换算32

Cursor

20.36%
按下载量换算24

Gemini CLI

9.76%
按下载量换算12

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills