e2ad1331cc
feat(测试): 新增Playwright和Vitest测试配置 feat(测试): 添加测试覆盖率报告生成功能 feat(测试): 实现前后端测试脚本集成 fix(测试): 修复测试密码不匹配问题 fix(测试): 修正URL等待策略 fix(测试): 调整错误消息选择器 refactor(测试): 重构测试目录结构 refactor(测试): 优化测试用例组织方式 docs: 更新测试报告文档 docs: 添加测试覆盖率报告模板 ci: 添加Docker测试环境配置 ci: 实现测试自动化脚本 chore: 更新依赖版本 chore: 添加测试相关配置文件
109 lines
2.7 KiB
YAML
109 lines
2.7 KiB
YAML
version: '3.8'
|
|
|
|
services:
|
|
# PostgreSQL测试数据库服务
|
|
postgres-test:
|
|
image: postgres:15-alpine
|
|
container_name: novalon-postgres-test
|
|
environment:
|
|
POSTGRES_DB: manage_system_test
|
|
POSTGRES_USER: novalon_test
|
|
POSTGRES_PASSWORD: novalon_test123
|
|
ports:
|
|
- "55433:5432"
|
|
volumes:
|
|
- postgres_test_data:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U novalon_test -d manage_system_test"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
networks:
|
|
- novalon-test-network
|
|
|
|
# 后端API测试服务
|
|
backend-test:
|
|
build:
|
|
context: ./novalon-manage-api
|
|
dockerfile: Dockerfile
|
|
container_name: novalon-backend-test
|
|
environment:
|
|
SPRING_PROFILES_ACTIVE: test
|
|
SPRING_R2DBC_URL: r2dbc:postgresql://postgres-test:5432/manage_system_test
|
|
SPRING_R2DBC_USERNAME: novalon_test
|
|
SPRING_R2DBC_PASSWORD: novalon_test123
|
|
SPRING_JPA_HIBERNATE_DDL_AUTO: update
|
|
ports:
|
|
- "8085:8084"
|
|
depends_on:
|
|
postgres-test:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:8084/actuator/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 40s
|
|
networks:
|
|
- novalon-test-network
|
|
volumes:
|
|
- ./test-results:/app/test-results
|
|
|
|
# 前端Web测试服务
|
|
frontend-test:
|
|
build:
|
|
context: ./novalon-manage-web
|
|
dockerfile: Dockerfile
|
|
container_name: novalon-frontend-test
|
|
ports:
|
|
- "3002:80"
|
|
depends_on:
|
|
backend-test:
|
|
condition: service_healthy
|
|
environment:
|
|
- VITE_API_BASE_URL=http://backend-test:8084
|
|
- NODE_ENV=test
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:80"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 40s
|
|
networks:
|
|
- novalon-test-network
|
|
volumes:
|
|
- ./test-results:/app/test-results
|
|
|
|
# Playwright测试服务
|
|
playwright-test:
|
|
build:
|
|
context: ./novalon-manage-web
|
|
dockerfile: Dockerfile.playwright
|
|
container_name: novalon-playwright-test
|
|
depends_on:
|
|
frontend-test:
|
|
condition: service_healthy
|
|
environment:
|
|
- BASE_URL=http://frontend-test:80
|
|
- CI=true
|
|
networks:
|
|
- novalon-test-network
|
|
volumes:
|
|
- ./test-results:/app/test-results
|
|
- ./playwright-report:/app/playwright-report
|
|
command: >
|
|
sh -c "
|
|
echo 'Waiting for frontend to be ready...' &&
|
|
sleep 10 &&
|
|
echo 'Starting Playwright tests...' &&
|
|
npx playwright test --reporter=json --reporter=html --reporter=junit
|
|
"
|
|
|
|
volumes:
|
|
postgres_test_data:
|
|
driver: local
|
|
|
|
networks:
|
|
novalon-test-network:
|
|
driver: bridge
|