commit 153734216414d88edc46a389697492e610e89c12 Author: Zhongwei Li Date: Sun Nov 30 08:23:11 2025 +0800 Initial commit diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..c41d801 --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,15 @@ +{ + "name": "integration-test-runner", + "description": "Run and manage integration test suites with environment setup, database seeding, and cleanup", + "version": "1.0.0", + "author": { + "name": "Claude Code Plugins", + "email": "[email protected]" + }, + "skills": [ + "./skills" + ], + "commands": [ + "./commands" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..4f147f9 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# integration-test-runner + +Run and manage integration test suites with environment setup, database seeding, and cleanup diff --git a/commands/run-integration.md b/commands/run-integration.md new file mode 100644 index 0000000..4908fa0 --- /dev/null +++ b/commands/run-integration.md @@ -0,0 +1,166 @@ +--- +description: Run integration test suites with proper setup and teardown +shortcut: rit +--- + +# Integration Test Runner + +Run integration tests with comprehensive environment setup, database seeding, service orchestration, and cleanup. + +## Purpose + +Execute integration tests that verify interactions between multiple system components: +- API endpoints with database operations +- Microservices communication +- Third-party service integrations +- Full request/response workflows +- Database transactions and state changes + +## Pre-Test Setup + +Before running integration tests, ensure: + +1. **Environment Configuration** + - Check for test environment variables + - Verify test database connections + - Confirm test API keys/credentials + - Validate service dependencies are available + +2. **Database Preparation** + - Create/reset test database + - Run migrations + - Seed test data + - Clear any existing test data + +3. **Service Dependencies** + - Start required services (Redis, message queues, etc.) + - Check service health endpoints + - Initialize mock services if needed + - Set up test containers (Docker/Testcontainers) + +4. **State Management** + - Clear caches + - Reset file system test directories + - Initialize test state + +## Test Execution + +Run integration tests with: + +```bash +# Run all integration tests +/run-integration + +# Run specific test suite +/run-integration api + +# Run with specific environment +/run-integration --env staging + +# Run with coverage +/run-integration --coverage +``` + +## Execution Process + +1. **Pre-flight checks** + - Validate environment configuration + - Check database connectivity + - Verify service availability + - Confirm no conflicting processes + +2. **Setup phase** + - Initialize test database + - Seed required data + - Start dependent services + - Configure test environment + +3. **Run tests** + - Execute test suites in order + - Capture detailed logs + - Report progress + - Handle test failures gracefully + +4. **Teardown phase** + - Clean up test data + - Stop test services + - Reset environment + - Generate test reports + +## Test Organization + +Structure integration tests by: +- **API routes** - Endpoint-specific tests +- **User workflows** - End-to-end user journeys +- **Service interactions** - Cross-service communication +- **Data flows** - Multi-step data processing + +## Reporting + +Generate comprehensive reports with: +- Test results (pass/fail counts) +- Execution time per test +- Failed test details with stack traces +- Code coverage (if enabled) +- Service logs for failures +- Database state at failure points + +## Cleanup + +After tests complete: +- Drop test database or truncate tables +- Stop test containers/services +- Remove temporary files +- Clear test caches +- Reset environment variables + +## Best Practices Applied + +- **Isolation** - Tests don't depend on each other +- **Idempotency** - Tests can run multiple times safely +- **Fast feedback** - Fail fast on setup errors +- **Clear reporting** - Easy to identify failures +- **Proper cleanup** - No test pollution +- **Realistic data** - Test data resembles production + +## Example Output + +``` +Integration Test Runner +======================= + +Setup Phase: + Database connection verified + Test database created and migrated + Test data seeded (50 users, 200 products) + Redis cache cleared + Services healthy: api, worker, notifications + +Running Tests: + API Authentication Tests (5/5 passed) - 2.3s + User Management Tests (12/12 passed) - 5.1s + Order Processing Tests (8/8 passed) - 8.7s + Payment Integration Tests (3/4 passed) - 4.2s + └─ test_refund_webhook_handling FAILED + Notification Tests (6/6 passed) - 3.1s + +Results: 34/35 tests passed (97.1%) +Total time: 23.4s +Coverage: 78.3% + +Teardown Phase: + Test database dropped + Services stopped + Temp files removed + +Report saved to: test-results/integration-2025-10-11-14-30.json +``` + +## Troubleshooting + +Common issues: +- **Connection refused** - Check service is running +- **Database errors** - Verify migrations are current +- **Timeout errors** - Increase test timeouts +- **Port conflicts** - Ensure test ports are available +- **Permission errors** - Check file/database permissions diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..dc4d122 --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,61 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:jeremylongshore/claude-code-plugins-plus:plugins/testing/integration-test-runner", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "fd8dcf4bc180653fbfffca306ed5c199f3c2751b", + "treeHash": "34955e9b007e78df88b0760a9e2c8440f36959c559dc28c0bbd266b45fa34f7c", + "generatedAt": "2025-11-28T10:18:31.352594Z", + "toolVersion": "publish_plugins.py@0.2.0" + }, + "origin": { + "remote": "git@github.com:zhongweili/42plugin-data.git", + "branch": "master", + "commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390", + "repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data" + }, + "manifest": { + "name": "integration-test-runner", + "description": "Run and manage integration test suites with environment setup, database seeding, and cleanup", + "version": "1.0.0" + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "b2d2955bd5158ac0c055808ba1aa89d0e5ab8028bc0a75d5fdff7d23a0da7f55" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "65aa43d279308612655b83eca08abdd49e5e78d035e0a8e47ea01c57dca96cb9" + }, + { + "path": "commands/run-integration.md", + "sha256": "74030384047accffa10b26c564d3f303ed1878cf7c43f6fbe3ec536a20ba99f5" + }, + { + "path": "skills/integration-test-runner/SKILL.md", + "sha256": "7839db2809e371659ead19b5a2cbca82e0ee816b86e642ee0eaaa2bdc8087f7a" + }, + { + "path": "skills/integration-test-runner/references/README.md", + "sha256": "b36b0b456d6e1089eac64c6d2920dfa0d9983367f448f8b5258b5d8c0e963055" + }, + { + "path": "skills/integration-test-runner/scripts/README.md", + "sha256": "4af303a4ea2f69c8aa03166291c419606709e3b7c70b3d4ecbbdd904d7427246" + }, + { + "path": "skills/integration-test-runner/assets/README.md", + "sha256": "2216e7cfeb53d3421361b00f8d187061885b38793881c766c2bfda4c30856349" + } + ], + "dirSha256": "34955e9b007e78df88b0760a9e2c8440f36959c559dc28c0bbd266b45fa34f7c" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file diff --git a/skills/integration-test-runner/SKILL.md b/skills/integration-test-runner/SKILL.md new file mode 100644 index 0000000..44d682f --- /dev/null +++ b/skills/integration-test-runner/SKILL.md @@ -0,0 +1,56 @@ +--- +name: running-integration-tests +description: | + This skill enables Claude to run and manage integration test suites. It automates environment setup, database seeding, service orchestration, and cleanup. Use this skill when the user asks to "run integration tests", "execute integration tests", or any command that implies running integration tests for a project, including specifying particular test suites or options like code coverage. It is triggered by phrases such as "/run-integration", "/rit", or requests mentioning "integration tests". The plugin handles database creation, migrations, seeding, and dependent service management. +allowed-tools: Read, Write, Edit, Grep, Glob, Bash +version: 1.0.0 +--- + +## Overview + +This skill empowers Claude to execute comprehensive integration tests, ensuring seamless interactions between various system components. It automates the often complex setup and teardown processes, providing reliable and repeatable test runs. + +## How It Works + +1. **Environment Preparation**: The plugin sets up the test environment, including creating/resetting databases, running migrations, and seeding test data. +2. **Test Execution**: The plugin executes the integration test suites, capturing detailed logs and reporting progress. +3. **Cleanup**: After the tests, the plugin cleans up the environment, dropping the test database, stopping services, and removing temporary files to prevent test pollution. + +## When to Use This Skill + +This skill activates when you need to: +- Run all integration tests for a project. +- Run a specific integration test suite (e.g., "API tests"). +- Run integration tests with code coverage analysis. + +## Examples + +### Example 1: Running All Integration Tests + +User request: "/run-integration" + +The skill will: +1. Prepare the test environment (database, services). +2. Execute all integration test suites defined in the project. +3. Generate a report with pass/fail counts and coverage metrics. +4. Clean up the test environment. + +### Example 2: Running a Specific Test Suite + +User request: "/run-integration api" + +The skill will: +1. Prepare the test environment. +2. Execute only the "api" integration test suite. +3. Generate a report specific to the "api" suite. +4. Clean up the test environment. + +## Best Practices + +- **Configuration**: Ensure test configurations are properly set up in `test/integration/config.json`, `.env.test`, or related files. +- **Dependencies**: Define all necessary services and dependencies in the test environment configuration. +- **Test Design**: Write focused integration tests that verify specific interactions between components. + +## Integration + +This skill works seamlessly with other plugins by ensuring a clean and isolated test environment. It avoids conflicts with other processes and provides reliable results. \ No newline at end of file diff --git a/skills/integration-test-runner/assets/README.md b/skills/integration-test-runner/assets/README.md new file mode 100644 index 0000000..292d9b1 --- /dev/null +++ b/skills/integration-test-runner/assets/README.md @@ -0,0 +1,7 @@ +# Assets + +Bundled resources for integration-test-runner skill + +- [ ] test_data.sql Example SQL script for seeding the test database. +- [ ] test_configuration.yaml Example configuration file for the test environment. +- [ ] report_template.html HTML template for generating test reports. diff --git a/skills/integration-test-runner/references/README.md b/skills/integration-test-runner/references/README.md new file mode 100644 index 0000000..c858c03 --- /dev/null +++ b/skills/integration-test-runner/references/README.md @@ -0,0 +1,8 @@ +# References + +Bundled resources for integration-test-runner skill + +- [ ] integration_testing_best_practices.md Provides best practices for writing and managing integration tests. +- [ ] environment_configuration.md Documents the required environment configurations for running the integration tests. +- [ ] test_suite_structure.md Explains the structure and organization of the test suites. +- [ ] api_documentation.md API documentation for services being tested. diff --git a/skills/integration-test-runner/scripts/README.md b/skills/integration-test-runner/scripts/README.md new file mode 100644 index 0000000..c7f8491 --- /dev/null +++ b/skills/integration-test-runner/scripts/README.md @@ -0,0 +1,8 @@ +# Scripts + +Bundled resources for integration-test-runner skill + +- [ ] setup_test_environment.sh Automates the setup of the testing environment, including database creation, seeding, and service orchestration. +- [ ] run_tests.sh Executes the integration tests with specified suites and options like code coverage. +- [ ] cleanup_test_environment.sh Cleans up the testing environment after the tests are run, ensuring no test pollution or leftover state. +- [ ] report_generator.py Generates detailed test reports with pass/fail counts, execution times, and code coverage metrics.