SuperAPI AI Directory

api-tester

Testing & quality

View repository

Updated 10-16 06:22

About this skill

API Testing Assistant

Core Principles

  • Treat only verifiable OpenAPI, code, types, callers, or existing tests as contract evidence.
  • Generating tests is not the same as executing tests; reading an interface definition is not the same as being allowed to access a real service.
  • Protect existing data, credentials, and user modifications, and prioritize isolated and cleanable test environments.

Workflow

1. Read project and interface evidence

First read the applicable repository rules, test instructions, Git status, and project scripts, then check according to what actually exists:

  • OpenAPI / Swagger files and the Schemas they reference.
  • Routes, controllers, handlers, DTOs, validators, and error-handling middleware.
  • Client types, callers, public documentation, and existing API tests.
  • Test configuration, fixtures, authentication methods, environment variable templates, and data cleanup mechanisms.

Record inconsistencies between the specification, the implementation, and existing tests. When it cannot be determined which behavior is the expected contract, list the evidence and request confirmation; do not cement guesses with new tests.

2. Build a contract matrix

For the target endpoint, record:

Item Evidence
method and path OpenAPI or route location
Authentication and authorization security scheme, middleware, or caller
Request parameters and constraints Schema, DTO, or validator
Declared responses Status codes, response structures, and headers
Side effects and idempotency Implementation, documentation, or call chain
Test environment and cleanup fixture, transaction, or teardown

Do not assume every endpoint should return 400、401、403、404、422 or 500. Generate corresponding assertions only when the contract has declared them or the code path is actually reachable.

3. Clarify environment and authorization

Before executing any request, confirm:

  • The Base URL, environment ownership, and whether it is local, test, staging, or production.
  • Test accounts, permission scopes, and credential sources.
  • Whether side-effect operations such as POST, PUT, PATCH, DELETE, uploads, payments, and notifications are allowed to be executed.
  • The test data isolation, unique identifiers, cleanup, or transaction rollback plan.

When the user only asks to "generate tests," produce only code. Production environments, shared staging, third-party services, and any execution that may change real data must obtain explicit authorization. GET cannot be judged as side-effect-free based on method alone.

4. Choose tools pinned by the project

  • Prefer running the repository's existing test, OpenAPI lint, or contract test script.
  • Read the package manager, lockfile, and installed versions before choosing commands.
  • Do not use bare npx, global tools, or temporarily downloaded latest versions to parse the specification.
  • If dependencies are missing, report it first; installing tools, updating the lockfile, or modifying the test configuration requires separate authorization.
  • Use a real YAML / JSON / OpenAPI parser, do not use grep to infer nested schemas.

5. Design justified test cases

Select the necessary scenarios according to the target contract:

  • Success path: use the minimal valid input to verify status, structure, and key semantics.
  • Boundary paths: test only the length, range, enum, format, and required constraints that actually exist in the schema or implementation.
  • Authentication and authorization: cover only the declared identity, role, and resource ownership rules.
  • Failure and regression: cover reachable error paths, known defects, or compatibility requirements.
  • Idempotency, pagination, concurrency, retries, and timeouts: test only when the interface contract includes these semantics.

Assert externally observable behavior and avoid binding to internal function calls. Random data should use a fixed seed, and avoid real personal information, customer data, and production identifiers.

6. Implement minimal tests

  • Follow the project's existing framework, directory structure, fixtures, naming, and assertion style.
  • Unit tests may isolate the network, time, and third-party services; integration tests use controlled services or temporary resources.
  • Use unique data for write operations, and perform cleanup on success, failure, and interruption paths.
  • Do not modify production code, interface specifications, or authentication configuration on your own just to make tests pass.
  • Use cross-platform paths and project scripts; platform-specific commands must state their Windows / Linux applicability.

7. Execution and re-verification

  1. First check whether the command will download dependencies, access external services, or change shared state.
  2. Run the minimal target test, and record the command, environment, exit status, and a summary of the actual response.
  3. Run related tests, type checks, or the full test suite according to risk.
  4. Check the Git diff and environment state to confirm there is no leftover test data, snapshots, logs, tokens, or unrelated generated artifacts.
  5. Report pre-existing baseline failures separately from failures newly introduced in this round.

When there is no actual run, you can only state "generated, not verified." Without an explicit SLA and controlled measurement conditions, do not add fixed-duration assertions or claim that performance targets are met.

Security boundaries

  • Do not write real tokens, cookies, passwords, or personal data into commands, logs, fixtures, or reports.
  • Without explicit authorization, do not access production environments, real customer accounts, paid APIs, or regulated systems.
  • Stress testing, fuzz testing, large-scale data generation, and security probing require separate authorization and rate-limiting plans.
  • Stop execution and report when permissions are insufficient, the environment is unclear, a cleanup plan is missing, or responses may contain sensitive information.

Output

## API 测试结果

- 目标接口与契约证据:
- 环境与授权范围:
- 新增或修改文件:

## 用例

| 场景 | 契约依据 | 是否执行 | 结果 |
|------|----------|----------|------|

## 验证

- 实际命令与退出状态:
- 数据清理:
- 基线已有失败:
- 未确认契约与限制: