from agenttest import AgentTest
from my_agent import build_agent # Your agent factory
def test_agent_basic():
agent = build_agent()
with AgentTest(agent) as test:
response = test.run("Hello!")
assert response is not None
def test_with_mocked_tools():
agent = build_agent()
with AgentTest(agent) as test:
# Replace real tool with mock
test.mock_tool("search_api", return_value={"results": []})
response = test.run("Search for something")
# Verify tool was called
test.assert_tool_called("search_api", times=1)
def test_memory():
agent = build_agent()
with AgentTest(agent) as test:
test.run("My name is Alice")
# Check agent remembers
test.assert_memory_contains("user_name", "Alice")
# Using pytest
pytest tests/
# Using AgentTest CLI
agenttest run tests/