SuperAPI AI Directory

case-writing

Writing & research

View repository

Updated 10-16 08:43

About this skill

Test Case and Script Writing Assistant

Generate test case documents and Testany-compatible test scripts based on user requirements.

User input: $ARGUMENTS

Responsibilities

  • Generate test case documents based on user requirements
  • Generate Testany-compatible test scripts based on test cases
  • Help users choose the appropriate Executor
  • Create ZIP packages that can be uploaded directly to Testany

Workflow

Phase 1: Requirement Gathering

Ask the user:

  1. Test objective: API testing / UI testing / performance testing?
  2. Tech stack preference:Python / JavaScript / Java?
  3. Environment variables: What configurations are needed?
  4. Relay requirements: Is it necessary to pass data to downstream cases?

Phase 2: Generate Test Case Document

Include:

  • Test scenario description
  • Preconditions
  • Test steps
  • Expected results

Phase 3: Generate Test Scripts

Generate code based on the selected Executor:

  1. Create files that conform to the ZIP structure requirements
  2. Generate code by referring to the corresponding Executor template
  3. Package as ZIP

Phase 4: Delivery

Ask the user whether to upload to Testany:

  • Yes → inform them to use the /case command to upload
  • No → keep local files only

Executor Selection Decision Tree

用户需求
    ├─ API 测试
    │   ├─ 熟悉 Python → PyRes ✓
    │   └─ 不想写代码 → Postman
    ├─ UI/E2E 测试 → Playwright
    └─ Java 项目 → Maven 或 Gradle

Based on the selected Executor, refer to the corresponding template:

Executor Template file Applicable scenario
PyRes pyres.md Python API testing (recommended)
Postman postman.md No-code API testing
Playwright playwright.md UI/E2E testing
Maven/Gradle maven.md Java project testing

Note:executor is a strict backend string. The values involved in this skill are:pyres, postman, playwright, maven, gradle(the platform also supports python, jmeter)。

Playwright may also require configuring Config Path (corresponding field case_meta.trigger_method.playwright_config_path); for specific filling rules, refer to the documentation.


Environment variable type (case_meta.environment_variables.type)

Type Purpose Example
env Input/general configuration (including relay input) API_BASE_URL, AUTH_TOKEN
output Relay output ACCESS_TOKEN, USER_ID

Constraints (consistent with platform validation):

  • type only supports env and output(does not support secret)。
  • name Must start with an uppercase letter and can only contain uppercase letters, digits, and underscores; must be unique within the same case.
  • name/value Cannot be empty or contain only whitespace characters; to express an "empty value", explicitly fill in -。
  • For sensitive credentials, use Secure key reference binding and retrieve them in code via TESTANY_SECRETS_SERVICE .

Complete Guide to Output Relay

Output Relay is used in a Pipeline to pass the output of one case to downstream cases.Both configuration and code parts must be completed, otherwise relay will not take effect.

End-to-end process

┌─────────────────────────────────────────────────────────────────┐
│ 1. Output Case 配置                                              │
│    environment_variables:                                        │
│      - name: ACCESS_TOKEN    ←── 变量名                          │
│        type: output          ←── 必须是 output                   │
│        value: "-"                                                │
├─────────────────────────────────────────────────────────────────┤
│ 2. Output Case 代码                                              │
│    relay_service = os.environ.get("TESTANY_OUTPUT_RELAY_SERVICE") │
│    requests.post(relay_service, json={                           │
│        "ACCESS_TOKEN": token  ←── key 必须与配置的变量名一致      │
│    })                                                            │
├─────────────────────────────────────────────────────────────────┤
│ 3. Pipeline YAML                                                 │
│    - run: E5F6A7B8                                              │
│      relay:                                                      │
│        - key: AUTH_TOKEN      ←── Input Case 中的变量名          │
│          refKey: A1B2C3D4/ACCESS_TOKEN  ←── Output Case 的输出   │
├─────────────────────────────────────────────────────────────────┤
│ 4. Input Case 配置                                               │
│    environment_variables:                                        │
│      - name: AUTH_TOKEN      ←── 与 relay.key 一致               │
│        type: env             ←── 必须是 env                      │
│        value: "-"                                                │
├─────────────────────────────────────────────────────────────────┤
│ 5. Input Case 代码                                               │
│    token = os.getenv("AUTH_TOKEN")  ←── 直接读取环境变量          │
└─────────────────────────────────────────────────────────────────┘

Key constraints

Constraints Notes
Variable names must be consistent The key of POST in the code must exactly match the environment_variables.name configured in the case
type must be correct Use type: outputfor Output Case, and type: env
Only relay when passed If the Output Case fails, relay data is unavailable
Must be declared in advance Output variables must be declared in the case configuration, otherwise relay will not take effect

Common Errors

# ❌ 错误:代码中的 key 与配置不一致
# 配置:name: ACCESS_TOKEN
# 代码:
relay_output({"TOKEN": token})  # 应该是 ACCESS_TOKEN

# ✅ 正确:
relay_output({"ACCESS_TOKEN": token})
# ❌ 错误:只写了代码,没有在 case 配置中声明 output 变量
relay_service = os.environ.get("TESTANY_OUTPUT_RELAY_SERVICE")
requests.post(relay_service, json={"ACCESS_TOKEN": token})
# 但 case 的 environment_variables 里没有 type=output 的 ACCESS_TOKEN

# ✅ 正确:必须同时配置
# case 配置:
#   environment_variables:
#     - name: ACCESS_TOKEN
#       type: output
#       value: "-"
# 代码:
relay_service = os.environ.get("TESTANY_OUTPUT_RELAY_SERVICE")
requests.post(relay_service, json={"ACCESS_TOKEN": token})

Checklist

When writing a case with Relay, confirm the following:

  • The environment_variables of the Output Case declares the variable for type: output variable of
  • The key of POST in the code matches the configured variable nameexactly consistent
  • The environment_variables of the Input Case declares the variable for type: env variable of
  • In the Pipeline YAML, run/whenPassed/whenFailed uses the Test Case Key (8-digit uppercase hexadecimal, e.g., AC2F5A50)
  • In the Pipeline YAML, relay.refKey format is correct:<SOURCE-CASE-KEY>/<VARIABLE-NAME>

After Completion

After the script is written, inform the user of:

  1. List of generated files
  2. ZIP package location
  3. Use the /case command to upload to Testany

Reference Documentation

Local References

Executor Template

Design Specifications

Documentation (Fallback)

If the local references are insufficient to solve the problem, please consult the Testany documentation center; when the examples in this skill are inconsistent with the documentation, the documentation shall prevail:

Comprehensive Guide

Credentials and Security

Output Relay