spoonos-testing-patternslisted
Install: claude install-skill Gabssama12/spoon-awesome-skill
# Testing Patterns
Comprehensive testing strategies for SpoonOS agents.
## Testing Pyramid
```
/\
/ \ E2E Tests (few)
/----\
/ \ Integration Tests (some)
/--------\
/ \ Unit Tests (many)
/------------\
```
## Unit Testing Tools
### Testing a Custom Tool
```python
# tests/test_tools.py
import pytest
from unittest.mock import AsyncMock, patch
from my_agent.tools import PriceTool, WalletTool
@pytest.mark.asyncio
async def test_price_tool_success():
"""Test successful price fetch."""
tool = PriceTool()
# Mock the HTTP response
with patch('aiohttp.ClientSession.get') as mock_get:
mock_response = AsyncMock()
mock_response.status = 200
mock_response.json = AsyncMock(return_value={
"bitcoin": {"usd": 50000, "usd_24h_change": 2.5}
})
mock_get.return_value.__aenter__.return_value = mock_response
result = await tool.execute(coin_id="bitcoin", currency="usd")
assert "50,000" in result
assert "2.50%" in result
@pytest.mark.asyncio
async def test_price_tool_not_found():
"""Test handling of unknown coin."""
tool = PriceTool()
with patch('aiohttp.ClientSession.get') as mock_get:
mock_response = AsyncMock()
mock_response.status = 200
mock_response.json = AsyncMock(return_value={})
mock_get.return_value.__aenter__.return_value = mock_response
result = await tool.execute(coin_id="un