Skill站外收录 @skilllib/skill-2014279401943281665
testing
执行并调试 DBHub 项目的单元测试与集成测试,支持多种数据库环境下的自动化测试流程,能够定位测试失败原因、处理容器化数据库启动问题,并验证代码变更的正确性,适用于本地开发与 CI/CD 场景。
测试与安全 AI 技能
Skills.MD
# Testing Skill
This skill helps you run and troubleshoot tests in the DBHub project.
## Quick Commands
Before running tests, consult [TESTING.md](../../../TESTING.md) for comprehensive documentation.
Common test commands:
- `pnpm test` - Run all tests
- `pnpm test:watch` - Run tests in watch mode
- `pnpm test:integration` - Run integration tests (requires Docker)
- `pnpm test src/connectors/__tests__/{db-type}.integration.test.ts` - Test specific database connector
## Integration Testing
Integration tests use [Testcontainers](https://testcontainers.com/) to run real database instances in Docker.
### Prerequisites Checklist
Before running integration tests, verify:
1. Docker is installed and running: `docker ps`
2. Sufficient Docker memory allocated (4GB+ recommended)
3. Network access to pull Docker images
### Database-Specific Tests
Test individual database connectors:
```bash
# PostgreSQL
pnpm test src/connectors/__tests__/postgres.integration.test.ts
# MySQL
pnpm test src/connectors/__tests__/mysql.integration.test.ts
# MariaDB
pnpm test src/connectors/__tests__/mariadb.integration.test.ts
# SQL Server
pnpm test src/connectors/__tests__/sqlserver.integration.test.ts
# SQLite
pnpm test src/connectors/__tests__/sqlite.integration.test.ts
# JSON RPC integration
pnpm test src/__tests__/json-rpc-integration.test.ts
```
## Troubleshooting
### Container Startup Issues
If containers fail to start:
```bash
# Verify Docker is running
docker ps
# Check disk space
docker system df
# Manually pull images
docker pull postgres:15-alpine
docker pull mysql:8.0
docker pull mariadb:10.11
docker pull mcr.microsoft.com/mssql/server:2019-latest
```
### SQL Server Timeout Issues
SQL Server containers require 3-5 minutes to start:
- Ensure Docker has 4GB+ memory allocated
- Run SQL Server tests separately: `pnpm test src/connectors/__tests__/sqlserver.integration.test.ts`
- Check timeout settings in test files
### Debug Failed Tests
```bash
# Run with verbose output
pnpm test:integration --reporter=verbose
# Run specific test pattern
pnpm test:integration -- --testNamePattern="PostgreSQL"
# Check container logs
docker logs <container_id>
```
## Test Architecture
All integration tests follow this pattern:
1. **Container Lifecycle**: Start database container → Connect → Setup test data → Run tests → Cleanup
2. **Shared Test Utilities**: Common patterns in `IntegrationTestBase` class
3. **Database-Specific Features**: Each database tests unique capabilities
4. **Error Handling**: Comprehensive testing of connection errors, invalid SQL, edge cases
## When to Use This Skill
Use this skill when:
- Asked to run tests or verify code changes
- Debugging test failures
- Setting up integration tests for new features
- Troubleshooting Docker or Testcontainers issues
- Adding new database connector tests
- Investigating CI/CD test failures
## Related Files
- [TESTING.md](../../../TESTING.md) - Comprehensive testing documentation
- `src/connectors/__tests__/` - Integration test files
- `vitest.config.ts` - Vitest configuration
- `.github/workflows/` - CI/CD test workflows
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「testing」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次