AgentSkillsCN

integration-testing

容器集成测试指南:构建隔离环境,执行构建与本地测试,验证运行时行为。不包括需依赖外部服务或 API 的测试。仅在集成开发者完成相关工作后方可启用。

SKILL.md
--- frontmatter
name: integration-testing
description: "Guidelines for testing container integrations: creating isolated environments, running builds and local tests, verifying runtime behavior. Excludes tests requiring external services/APIs. Works after integration-developer completes."

Integration Testing Skill

This skill provides guidance for testing and validating container integrations. The integration-tester verifies that builds succeed, local tests pass, and containers run correctly, using isolated environments for reproducible results.

IMPORTANT: Only test what can run locally. Tests requiring external services, APIs, databases, or network dependencies are EXCLUDED.


Core Principle

You validate local functionality; you don't test external integrations.

code
Integration Developer creates integration
              ↓
     [Integration Tester]
              ↓
    Environment → Build → Local Tests → Startup Verify
              ↓
         Pass OR Fail with detailed report

Technology Agnostic

This skill is technology-agnostic. All implementation details depend on:

code
.constraints/TECHNOLOGY.md

Always read this file first to understand:

  • Programming language(s)
  • Build tools and commands
  • Test framework and commands
  • Package manager and dependencies
  • Runtime requirements

Also read the container's README to understand its specific directory structure and commands.


Testing Scope: Local Only

INCLUDE in Testing

CategoryExamples
Unit testsPure logic, calculations, transformations
Component testsInternal behavior with mocks
Build verificationCompilation, type checking, linting
Import verificationAll modules resolve correctly
Startup verificationEntrypoint runs without immediate crash
Mocked testsTests using mocked external dependencies

EXCLUDE from Testing

CategoryExamplesWhy Excluded
External API callsREST calls to third-party servicesAPIs not available
Database connectionsPostgreSQL, MongoDB, RedisDatabase not running
Message queuesRabbitMQ, Kafka, SQSQueue not available
Cloud servicesS3, Azure Blob, GCSCredentials unavailable
Network-dependentTests requiring internetNetwork may be restricted

Test Filtering Commands

bash
# Python - exclude external markers
pytest -m "not external and not requires_db and not e2e"

# Node.js - ignore external directories
npm test -- --testPathIgnorePatterns="e2e|external"

# Go - short mode skips long/external tests
go test -short ./...

Success Factors

1. Environment Isolation

CriterionMeasure
Container-LocalEnv created inside container folder
Not GlobalNo system/global package pollution
GitignoredEnv directory in .gitignore
ReproducibleCan be recreated from scratch

2. Build Success

CriterionMeasure
No Compilation ErrorsAll source files compile
Type SafetyType checks pass (if applicable)
Dependencies ResolvedAll imports/requires work

3. Local Test Success

CriterionMeasure
Local Tests RunAll locally-runnable tests executed
Local Tests Pass100% pass rate for local tests
External SkippedExternal tests properly excluded

4. Startup Success

CriterionMeasure
No Immediate ErrorsEntrypoint runs without crash
Config LoadsConfiguration parsing works
Connection Errors OKExternal service errors expected

Input: What You Receive

From Integration Developer

code
{container}/
├── [entrypoint files]          # Structure varies by language
├── [scripts/]                  # Launch scripts (if created)
├── [test directories]          # Structure varies by language
├── .env.example                # Environment template
└── README.md                   # Documentation with commands

Note: Directory structure varies. Always read README/specs first.

From Container Specs

code
{container}/.specs/integration.md     # Expected behavior
{container}/.specs/technology.md      # Tech stack

From Constraints

code
.constraints/TECHNOLOGY.md            # Language, tools, commands

Output: What You Create

1. Isolated Environment

code
{container}/.venv/              # Python
{container}/node_modules/       # Node.js (default)
{container}/.goenv/             # Go (if needed)
{container}/target/             # Rust

2. Updated .gitignore

code
{container}/.gitignore          # With env directory entry

3. Test Results Report

Structured report with all validation results.


Workflow

Step 1: Read Constraints, Specs, and README

code
Read (in order):
├── .constraints/TECHNOLOGY.md         → Language, tools
├── {container}/.specs/integration.md  → Expected behavior
├── {container}/.specs/technology.md   → Container tech stack
└── {container}/README.md              → Build/test commands

Step 2: Create Isolated Environment

Create environment INSIDE the container folder:

Python

bash
cd {container}
python -m venv .venv
source .venv/bin/activate  # or .venv\Scripts\activate
pip install -r requirements.txt

Node.js

bash
cd {container}
npm install

Go

bash
cd {container}
go mod download

Step 3: Update .gitignore

Ensure {container}/.gitignore includes:

gitignore
# Virtual environment
.venv/
node_modules/
.goenv/
target/

# Environment
.env

Step 4: Run Build Checks

LanguageCommand
Pythonpython -m py_compile / mypy
TypeScriptnpm run build / tsc
Gogo build ./...
Rustcargo build

Step 5: Run Local Tests Only

Execute ONLY locally-runnable tests:

FrameworkCommand (Local Only)
pytestpytest -m "not external and not e2e" -v
jestnpm test -- --testPathIgnorePatterns="e2e|external"
go testgo test -short ./...

Identifying external tests:

  • Look for markers: @pytest.mark.external, @pytest.mark.requires_db
  • Check directories: tests/e2e/, tests/external/
  • Scan for imports of HTTP clients, database drivers, SDK clients

Step 6: Verify Startup

  1. Set up minimal environment (dummy values for external services)
  2. Run entrypoint with short timeout
  3. Check for immediate errors (syntax, import, config)
  4. Ignore connection errors to external services (expected)

Step 7: Generate Report

markdown
## Integration Test Report: {container}

### Environment Setup
- Virtual environment: ✓/✗
- .gitignore updated: ✓/✗
- Dependencies: ✓/✗

### Build Verification
- Status: ✓ PASS / ✗ FAIL
- Errors: {list}

### Local Tests (External Excluded)
- Total local: {n}
- Passed: {n}
- Failed: {n}
- Skipped (external): {n}
- Details: {per test}

### Startup Verification
- Entrypoint runs: ✓/✗
- Startup errors: {list - excluding connection errors}
- Connection errors (expected): {list - informational}

### Overall: ✓ PASS / ✗ FAIL

### Issues (if any)
1. {detailed issue}

### Notes
- External tests skipped: {list}
- These will be tested when services are available

Environment Isolation Patterns

Why Container-Local Environments

BenefitExplanation
No ConflictsEach container has isolated deps
Parallel TestingTest multiple containers simultaneously
Clean StateFresh environment each time
Production-LikeMirrors containerized deployment

Directory Structure

code
{container}/
├── .venv/              # Isolated environment (gitignored)
├── .gitignore          # Includes .venv/
├── [source files]      # Structure varies
├── [test files]        # Structure varies
└── ...

.gitignore Template

gitignore
# Environments
.venv/
.goenv/
node_modules/
target/

# Config
.env
.env.local

# Cache
.pytest_cache/
__pycache__/
*.pyc
.coverage

Error Reporting Patterns

Build Error

markdown
### Error: Build Failure

**Type**: Build Error
**Location**: {container}/module.py:42
**Message**:

SyntaxError: unexpected indent

code

**Context**:
```python
def process():
    result = compute()
     return result  # <- extra indent

Possible Cause: Extra space before return statement

code

### Test Failure

```markdown
### Error: Test Failure

**Type**: Test Failure
**Test**: test_validation
**Location**: {container}/tests/test_core.py:15
**Message**:

AssertionError: Expected True, got False

code

**Possible Cause**: Validation logic not handling edge case

What NOT to Report as Errors

markdown
# These are EXPECTED and should NOT fail the test:

ConnectionRefusedError: [Errno 111] Connection refused (database)
TimeoutError: Connection to api.example.com timed out
redis.exceptions.ConnectionError: Error connecting to Redis

Quality Checklists

Before Reporting

Environment

  • Created inside container folder
  • Not in global/system location
  • .gitignore includes env directory
  • Dependencies installed successfully

Build

  • All source files processed
  • No compilation errors
  • Imports resolve correctly

Local Tests

  • Identified local vs external tests
  • External tests excluded
  • All local tests executed
  • Results captured with details

Startup

  • Entrypoint attempted
  • Immediate errors captured
  • Connection errors ignored (expected)

Anti-Patterns to Avoid

Anti-PatternProblemSolution
Global EnvironmentPollutes system, conflictsUse container-local env
Missing .gitignoreEnv committed to repoAlways update .gitignore
Running External TestsFail due to missing servicesFilter to local only
Failing on Connection ErrorsExpected when services unavailableIgnore them
Vague Error ReportsHard to debugInclude file:line, context
Fixing IssuesNot your roleReport and hand back
Assuming StructureBreaks on non-standard layoutsRead README first

Coordination

Report Back Contains

  1. Environment status - Created? Gitignored?
  2. Build results - Pass/fail with errors
  3. Local test results - Count, pass/fail, external skipped
  4. Startup results - Runs? Immediate errors?
  5. Detailed errors - For integration-developer to fix

Handoff to Integration Developer

Your error report enables fixes by providing:

  • Exact location (file:line)
  • Error message
  • Context (code snippet)
  • Possible cause

Do NOT

  • Fix issues yourself
  • Modify any code
  • Skip local validation steps
  • Report connection errors as failures
  • Assume specific directory structures