Este directorio contiene una suite completa de tests funcionales para verificar que el modelo de IA responde correctamente a diferentes tipos de solicitudes.
Tests completos end-to-end que verifican la funcionalidad del agente:
-
✅ Test 1: Chat Conversacional (
test_simple_chat)- Prueba respuestas a saludos y preguntas simples
- Verifica que el agente puede mantener conversaciones básicas
-
✅ Test 2: Procesamiento de Texto (
test_text_processing)- Resúmenes de texto
- Traducción
- Análisis de sentimiento
- Corrección gramatical
-
✅ Test 3: Operaciones Aritméticas (
test_arithmetic_operations)- Suma, resta, multiplicación, división
- Funciones matemáticas (raíz cuadrada, etc.)
- Verifica el uso de la tool
calculator
-
✅ Test 4: Generación de Código (
test_code_generation)- Funciones en Rust
- Ejemplos de async/await
- Código en Python y JavaScript
- Snippets útiles
-
✅ Test 5: Comprensión de Contexto (
test_context_comprehension)- Mantener contexto entre mensajes
- Recordar información previa
- Respuestas contextuales
-
✅ Test 6: Edición de Archivos (
test_file_editing)- Leer archivos
- Escribir contenido
- Verificar existencia de archivos
-
✅ Test 7: Comandos de Terminal (
test_terminal_commands)- Ejecución de comandos seguros
- Detección de comandos peligrosos
- Confirmación de operaciones riesgosas
-
✅ Test 8: Uso de Herramientas (
test_specific_tools)- Calculator
- Search
- Analyzer
- Formatter
-
✅ Test 9: Tareas Multi-paso (
test_complex_multistep_task)- Análisis complejo de código
- Generación con explicaciones
- Comparaciones detalladas
-
✅ Test 10: Manejo de Errores (
test_error_handling)- Prompts vacíos
- Prompts muy largos
- Comandos peligrosos
- Requests inseguros
-
✅ Test 11: Integración Completa (
test_full_integration_scenario)- Escenario realista de desarrollo
- Múltiples interacciones secuenciales
Tests unitarios para cada herramienta individual:
- Calculator Tool
- File Read/Write Tools
- List Directory Tool
- Shell Execute Tool
- Git Operations
- Search Tool
- Formatter Tool
- Analyzer Tool
- Documentation Extraction
- Test Runner
- Context Gathering
- Dependency Analysis
Tests del sistema de clasificación inteligente:
- Clasificación de tareas simples
- Clasificación de código
- Clasificación de tareas complejas
- Routing al modelo rápido
- Routing al modelo pesado
- Estimación de tiempos
- Detección de patrones peligrosos
- Balance de carga
- Priorización de tareas
cargo test# Tests de clasificación (no requieren Ollama)
cargo test --test classification_tests
# Tests de herramientas (no requieren Ollama)
cargo test --test tool_tests
# Tests funcionales (requieren Ollama corriendo)
cargo test --test functional_tests -- --ignored# Test específico de chat
cargo test --test functional_tests test_simple_chat -- --ignored --nocapture
# Test de cálculo aritmético
cargo test --test functional_tests test_arithmetic_operations -- --ignored --nocapture
# Test de generación de código
cargo test --test functional_tests test_code_generation -- --ignored --nocapture# Mostrar println! en tests
cargo test -- --nocapture
# Mostrar solo tests que fallan
cargo test -- --test-threads=1Requiere Ollama corriendo:
# Iniciar Ollama
ollama serve
# En otra terminal, descargar modelos
ollama pull qwen3:0.6b
ollama pull qwen3:8bConfiguración opcional:
Crea config.json en la raíz del proyecto:
{
"fast_model": {
"provider": "ollama",
"url": "http://localhost:11434",
"model": "qwen3:0.6b",
"temperature": 0.7
},
"heavy_model": {
"provider": "ollama",
"url": "http://localhost:11434",
"model": "qwen3:8b",
"temperature": 0.7
}
}No requieren servicios externos, se ejecutan automáticamente con:
cargo test| Categoría | Tests | Estado |
|---|---|---|
| Chat Simple | 3 prompts | ✅ |
| Procesamiento Texto | 4 escenarios | ✅ |
| Aritmética | 5 operaciones | ✅ |
| Generación Código | 4 lenguajes | ✅ |
| Comprensión Contexto | 3 seguimientos | ✅ |
| Edición Archivos | 3 operaciones | ✅ |
| Comandos Terminal | 3 comandos | ✅ |
| Herramientas | 4 tools | ✅ |
| Multi-paso | 3 escenarios | ✅ |
| Manejo Errores | 5 casos límite | ✅ |
| Total | 37+ tests | ✅ |
- Verificar Ollama está corriendo:
curl http://localhost:11434/api/tags- Verificar modelos descargados:
ollama list- Ver logs detallados:
RUST_LOG=debug cargo test --test functional_tests -- --ignored --nocapture- Test individual con tracing:
RUST_LOG=neuro=debug cargo test --test functional_tests test_simple_chat -- --ignored --nocapture#[tokio::test]
#[ignore] // Si requiere Ollama
async fn test_mi_funcionalidad() {
let orchestrator = create_test_orchestrator().await.unwrap();
let prompt = "Mi pregunta al modelo";
match orchestrator.process(prompt).await {
Ok(response) => {
match response {
OrchestratorResponse::Immediate { content, .. } => {
assert!(!content.is_empty());
// Tus verificaciones aquí
}
_ => {}
}
}
Err(e) => {
panic!("Error: {}", e);
}
}
}#[tokio::test]
async fn test_mi_tool() {
// Setup
let temp_dir = TempDir::new().unwrap();
// Acción
let result = mi_operacion();
// Verificación
assert!(result.is_ok());
}#[test]
fn test_mi_clasificacion() {
let queries = vec!["pregunta 1", "pregunta 2"];
for query in queries {
let task_type = classify_by_length_and_keywords(query);
assert_eq!(task_type, TestTaskType::Expected);
}
}-
Tests marcados con
#[ignore]requieren Ollama corriendo y deben ejecutarse explícitamente con-- --ignored -
Timeouts: Los tests con el modelo pesado pueden tardar hasta 60 segundos
-
Recursos: Los tests funcionales completos consumen ~500MB de RAM
-
Orden: Los tests se ejecutan en paralelo por defecto. Usa
--test-threads=1para ejecución secuencial -
Limpieza: Los archivos temporales se limpian automáticamente usando
tempfile
Para integración continua, ejecuta solo tests que no requieren Ollama:
# Tests rápidos (sin Ollama)
cargo test --lib
cargo test --test tool_tests
cargo test --test classification_tests
# Tests completos (con Ollama en CI)
cargo test -- --ignored --test-threads=1Para agregar tests:
- Identifica el tipo de test (funcional, tool, clasificación)
- Sigue la plantilla correspondiente
- Agrega documentación clara
- Ejecuta
cargo testpara verificar - Actualiza este README si es necesario
Última actualización: 7 de enero de 2026 Versión de tests: 1.0.0 Compatibilidad: neuro v0.1.0