7.7 KiB
Swarms Test Suite
This directory contains comprehensive tests for the Swarms framework, covering all major components including agents, workflows, tools, utilities, and more.
📁 Directory Structure
Core Test Files
test_comprehensive_test.py- Main comprehensive test suite that runs all major Swarms componentstest___init__.py- Package initialization testsrequirements.txt- Test dependencies (swarms, pytest, matplotlib, loguru)
Test Categories
🤖 Agent Tests (/agent/)
Tests for individual agent functionality and behavior:
/agents/ - Core agent functionality
test_agent_logging.py- Agent logging and monitoring capabilitiestest_create_agents_from_yaml.py- YAML-based agent creationtest_litellm_args_kwargs.py- LiteLLM argument handlingtest_llm_args.py- LLM argument processingtest_llm_handling_args.py- LLM argument managementtest_tool_agent.py- Tool-enabled agent functionality
/benchmark_agent/ - Agent performance and benchmarking
test_agent_benchmark_init.py- Agent benchmark initializationtest_agent_exec_benchmark.py- Agent execution benchmarkingtest_auto_test_eval.py- Automated test evaluationtest_github_summarizer_agent.py- GitHub summarization agenttest_profiling_agent.py- Agent performance profiling
🏗️ Structure Tests (/structs/)
Tests for Swarms structural components and workflows:
test_agent.py- Core Agent class functionalitytest_agent_features.py- Agent feature testingtest_agent_rearrange.py- Agent rearrangement capabilitiestest_agentrearrange.py- Alternative agent rearrangement teststest_airflow_swarm.py- Airflow integrationtest_auto_swarm_builder_fix.py- Auto swarm builder fixestest_auto_swarms_builder.py- Automated swarm constructiontest_base_workflow.py- Base workflow functionalitytest_base.py- Base class implementationstest_board_of_directors_swarm.py- Board of directors swarm patterntest_concurrent_workflow.py- Concurrent workflow executiontest_conversation.py- Conversation managementtest_forest_swarm.py- Forest swarm architecturetest_graph_workflow_comprehensive.py- Graph-based workflowstest_groupchat.py- Group chat functionalitytest_majority_voting.py- Majority voting mechanismstest_moa.py- Mixture of Agents (MoA) testingtest_multi_agent_collab.py- Multi-agent collaborationtest_multi_agent_orchestrator.py- Multi-agent orchestrationtest_reasoning_agent_router_all.py- Reasoning agent routingtest_recursive_workflow.py- Recursive workflow patternstest_round_robin_swarm.py- Round-robin swarm schedulingtest_sequential_workflow.py- Sequential workflow executiontest_spreadsheet.py- Spreadsheet swarm functionalitytest_swarm_architectures.py- Various swarm architecturestest_yaml_model.py- YAML model configuration
🔧 Tools Tests (/tools/)
Tests for tool integration and functionality:
test_base_tool.py- Base tool class functionalitytest_output_str_fix.py- Output string formatting fixestest_parse_tools.py- Tool parsing and executiontest_support_mcp.py- MCP (Model Context Protocol) support
🛠️ Utilities Tests (/utils/)
Tests for utility functions and helpers:
test_acompletions.py- Async completion handlingtest_auto_check_download.py- Automatic download checkingtest_display_markdown_message.py- Markdown message displaytest_docstring_parser.py- Docstring parsing utilitiestest_extract_code_from_markdown.py- Code extraction from markdowntest_formatter.py- Text formatting utilitiestest_litellm_wrapper.py- LiteLLM wrapper functionalitytest_math_eval.py- Mathematical expression evaluationtest_md_output.py- Markdown output handlingtest_metrics_decorator.py- Metrics collection decoratorstest_pdf_to_text.py- PDF to text conversiontest_try_except_wrapper.py- Error handling wrappers
🎨 Artifacts Tests (/artifacts/)
Tests for artifact management and versioning:
test_artifact_main.py- Core artifact functionalitytest_artifact_output_types.py- Artifact output type handling
💬 Communication Tests (/communication/)
Tests for communication and conversation management:
test_conversation.py- Conversation handling and persistence
📊 AOP (Aspect-Oriented Programming) Tests (/aop/)
Advanced testing with benchmarking and performance analysis:
aop_benchmark.py- Comprehensive AOP benchmarking suitetest_data/- Benchmark data and resultsaop_benchmark_data/- Benchmark results and visualizationsimage1.jpg,image2.png- Test images
📈 Telemetry Tests (/telemetry/)
Tests for telemetry and monitoring:
test_user_utils.py- User utility telemetry
🚀 Running Tests
Prerequisites
Install test dependencies:
pip install -r requirements.txt
Running All Tests
pytest
Running Specific Test Categories
# Run agent tests
pytest agent/
# Run structure tests
pytest structs/
# Run utility tests
pytest utils/
# Run tool tests
pytest tools/
Running Individual Test Files
# Run comprehensive test suite
pytest test_comprehensive_test.py
# Run specific test file
pytest structs/test_agent.py
Running with Coverage
pytest --cov=swarms --cov-report=html
📋 Test Features
Comprehensive Testing
- Agent Functionality: Complete testing of agent creation, execution, and management
- Workflow Testing: Various workflow patterns including sequential, concurrent, and recursive
- Tool Integration: Testing of tool parsing, execution, and MCP support
- Performance Benchmarking: AOP benchmarking with multiple LLM providers
- Error Handling: Comprehensive error handling and recovery testing
Test Data
- Benchmark results with CSV and Excel exports
- Performance visualizations (PNG charts)
- Test images for multimodal testing
- Conversation cache files for persistence testing
Supported LLM Providers
The AOP benchmark tests support multiple LLM providers:
- OpenAI (GPT-4o, GPT-4o-mini, GPT-4-turbo)
- Anthropic (Claude 3.5 Sonnet, Claude 3 Haiku, Claude 3 Sonnet)
- Google (Gemini 1.5 Pro, Gemini 1.5 Flash)
- Meta (Llama 3.1 8B, Llama 3.1 70B)
🔧 Configuration
Environment Variables
Tests require the following environment variables:
OPENAI_API_KEY- OpenAI API key for testing- Additional API keys for other providers (optional)
Test Configuration
- Maximum agents: 20 (configurable in AOP benchmark)
- Requests per test: 20
- Concurrent requests: 5
- Timeout settings: Configurable per test type
📊 Benchmarking
The AOP benchmark suite provides:
- Performance metrics across multiple LLM providers
- Memory usage tracking
- Response time analysis
- Throughput measurements
- Visual performance reports
🐛 Debugging
Verbose Output
pytest -v
Debug Mode
pytest --pdb
Logging
Tests use Loguru for comprehensive logging. Check console output for detailed test execution logs.
📝 Contributing
When adding new tests:
- Follow the existing directory structure
- Use descriptive test names
- Include proper docstrings
- Add appropriate fixtures and mocks
- Update this README if adding new test categories
🔍 Test Coverage
The test suite aims for comprehensive coverage of:
- ✅ Agent creation and execution
- ✅ Workflow patterns and orchestration
- ✅ Tool integration and execution
- ✅ Utility functions and helpers
- ✅ Error handling and edge cases
- ✅ Performance and benchmarking
- ✅ Communication and conversation management
- ✅ Artifact management and versioning