agentleFS
Vasallo94Vasallo94/obsidian-mcp-server/.agents/skills/test-runner/SKILL.md

Test Runner

Skill9 starsChanged 7 months agoMITView on GitHub

Skill para ejecutar y gestionar tests. Incluye patrones de testing, fixtures comunes, y estrategias de debugging de tests fallidos.

The file

Files
SKILL.md

Test Runner Skill

Cuándo usar esta skill

  • Cuando ejecutes tests del proyecto.
  • Cuando añadas nuevos tests.
  • Cuando debuggees tests que fallan.
  • Cuando necesites verificar cobertura.

Comandos de Ejecución

Ejecutar todos los tests

uv run pytest tests/

Ejecutar test específico

# Por archivo
uv run pytest tests/test_basic.py

# Por función
uv run pytest tests/test_basic.py::test_function_name

# Por clase
uv run pytest tests/test_basic.py::TestClassName

Opciones útiles

# Verbose - más detalle
uv run pytest tests/ -v

# Stop en primer fallo
uv run pytest tests/ -x

# Solo tests que fallaron antes
uv run pytest tests/ --lf

# Mostrar prints
uv run pytest tests/ -s

# Combinado: verbose, stop, prints
uv run pytest tests/ -vxs

Estructura de Tests

Los tests están en tests/:

tests/
├── conftest.py           # Fixtures compartidas
├── test_basic.py         # Tests de herramientas básicas
├── test_security.py      # Tests de seguridad/paths
├── test_agents.py        # Tests de carga de skills
├── test_connection_logic.py  # Tests de conexiones semánticas
└── test_image_indexing.py    # Tests de indexación de imágenes

Patrón para Nuevos Tests

"""
Tests para {módulo}.
"""

import pytest
import anyio  # Para tests async

from obsidian_mcp.module import function_to_test


class TestFunctionName:
    """Tests para function_to_test."""

    def test_caso_normal(self) -> None:
        """Verifica comportamiento normal."""
        result = function_to_test("input")
        assert result == "expected"

    def test_caso_error(self) -> None:
        """Verifica manejo de errores."""
        with pytest.raises(ValueError):
            function_to_test(None)

    @pytest.mark.asyncio
    async def test_async_function(self) -> None:
        """Verifica función asíncrona."""
        result = await async_function()
        assert result is not None

Fixtures Comunes

En conftest.py:

import pytest
from pathlib import Path


@pytest.fixture
def test_vault(tmp_path: Path) -> Path:
    """Crea un vault temporal para tests."""
    vault = tmp_path / "test_vault"
    vault.mkdir()
    # Crear estructura básica
    (vault / "note1.md").write_text("# Test Note")
    return vault


@pytest.fixture
def sample_note(test_vault: Path) -> Path:
    """Crea una nota de ejemplo."""
    note = test_vault / "sample.md"
    note.write_text("---\ntags: [test]\n---\n# Sample")
    return note

Debugging Tests Fallidos

1. Ver output detallado

uv run pytest tests/test_failing.py -vvs

2. Usar breakpoint

def test_something():
    result = function()
    breakpoint()  # Pausa aquí
    assert result == expected

Luego ejecutar:

uv run pytest tests/test_file.py -s

3. Ver traceback completo

uv run pytest tests/ --tb=long

Marcadores Útiles

# Saltar test
@pytest.mark.skip(reason="Not implemented yet")
def test_future_feature():
    ...

# Saltar condicionalmente
@pytest.mark.skipif(condition, reason="...")
def test_conditional():
    ...

# Esperar fallo
@pytest.mark.xfail(reason="Known bug")
def test_known_issue():
    ...

Variables de Entorno para Tests

Algunos tests necesitan configuración:

# Ejecutar con vault de prueba
OBSIDIAN_VAULT_PATH=/tmp/test_vault uv run pytest tests/

Checklist Pre-Push

Antes de hacer push, ejecutar suite completa:

# Todos los tests deben pasar
uv run pytest tests/ -v

# Verificar que no hay warnings críticos
uv run pytest tests/ -W error

Reports

Para generar reporte HTML (si pytest-html está instalado):

uv run pytest tests/ --html=report.html

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.