AgentSkillsCN

Run Tests

运行测试

SKILL.md

Run Tests - Skill

Descripción

Ejecuta suite de tests completa: Python (pytest), JavaScript (jest), PHP (PHPUnit). Genera reporte de cobertura.

Cuándo usar

code
"Ejecuta los tests"
"¿Qué tests están fallando?"
"Mira la cobertura de tests"
"Necesito saber si todo funciona"

Flujo de Ejecución

Python Tests (pytest)

bash
# 1. Setup
cd /home/pepe/runart-foundry
python -m venv venv 2>/dev/null || echo "venv exists"
source venv/bin/activate

# 2. Instalar dependencias
pip install -q -r requirements.txt

# 3. Ejecutar tests con cobertura
pytest tests/ \
  -v \
  --cov=apps --cov=tools \
  --cov-report=html:htmlcov \
  --tb=short \
  -x  # Para en primer error

# 4. Generar reporte
coverage report --skip-covered

JavaScript Tests (si existen)

bash
# 1. Setup
cd /home/pepe/runart-foundry
npm install --silent

# 2. Ejecutar tests
npm run test -- --coverage 2>/dev/null || echo "No Jest config"

# 3. Reporte
coverage report

PHP Tests (PHPUnit)

bash
# 1. Setup
cd /home/pepe/runart-foundry/wp-content

# 2. Ejecutar PHPUnit (si existe)
vendor/bin/phpunit --coverage-html coverage/ 2>/dev/null || echo "No PHPUnit"

# 3. Reporte
cat coverage/index.html | grep -o "coverage.*%"

Interpretación de Resultados

✅ TODO BIEN

code
tests/test_*.py .............. PASSED
coverage: 85%

→ Proceder con confianza

⚠️ WARNINGS (continuable)

code
tests/test_*.py ......F....... FAILED (1)
coverage: 72%

→ Revisar failed test, decidir si es crítico

❌ CRÍTICO

code
tests/test_*.py ERROR
coverage: < 60%
ImportError, SyntaxError

→ NO proceder, debuggear primero

Casos Especiales

Run tests específicos

bash
pytest tests/test_runmedia_optimizer.py -v

Tests de integración (lentos, opcional)

bash
pytest tests/ -v -m integration

Tests de rendimiento

bash
pytest tests/ -v --timeout=30 --durations=10

Salida Esperada

code
===================== test session starts ======================
collected 127 items

tests/test_colors.py::test_dominant_color PASSED               [1%]
tests/test_colors.py::test_color_palette PASSED               [2%]
...
tests/test_optimizer.py::test_webp_conversion PASSED           [98%]
tests/test_runmedia_cli.py::test_cli_help PASSED              [99%]
tests/test_integration_wordpress.py::test_health_check PASSED  [100%]

========== 127 passed in 3.24s, coverage 85% ===========

Documentación