mirror of
https://github.com/FuzzingLabs/fuzzforge_ai.git
synced 2026-02-13 02:32:47 +00:00
- add configuration file for 'ruff'.
- fix most of 'ruff' lints.
- format 'backend' package using 'ruff'.
FuzzForge Test Suite
Comprehensive test infrastructure for FuzzForge modules and workflows.
Directory Structure
tests/
├── conftest.py # Shared pytest fixtures
├── unit/ # Fast, isolated unit tests
│ ├── test_modules/ # Module-specific tests
│ │ ├── test_cargo_fuzzer.py
│ │ └── test_atheris_fuzzer.py
│ ├── test_workflows/ # Workflow tests
│ └── test_api/ # API endpoint tests
├── integration/ # Integration tests (requires Docker)
└── fixtures/ # Test data and projects
├── test_projects/ # Vulnerable projects for testing
└── expected_results/ # Expected output for validation
Running Tests
All Tests
cd backend
pytest tests/ -v
Unit Tests Only (Fast)
pytest tests/unit/ -v
Integration Tests (Requires Docker)
# Start services
docker-compose up -d
# Run integration tests
pytest tests/integration/ -v
# Cleanup
docker-compose down
With Coverage
pytest tests/ --cov=toolbox/modules --cov=src --cov-report=html
Parallel Execution
pytest tests/unit/ -n auto
Available Fixtures
Workspace Fixtures
temp_workspace: Empty temporary workspacepython_test_workspace: Python project with vulnerabilitiesrust_test_workspace: Rust project with fuzz targets
Module Fixtures
atheris_fuzzer: AtherisFuzzer instancecargo_fuzzer: CargoFuzzer instancefile_scanner: FileScanner instance
Configuration Fixtures
atheris_config: Default Atheris configurationcargo_fuzz_config: Default cargo-fuzz configurationgitleaks_config: Default Gitleaks configuration
Mock Fixtures
mock_stats_callback: Mock stats callback for fuzzingmock_temporal_context: Mock Temporal activity context
Writing Tests
Unit Test Example
import pytest
@pytest.mark.asyncio
async def test_module_execution(cargo_fuzzer, rust_test_workspace, cargo_fuzz_config):
"""Test module execution"""
result = await cargo_fuzzer.execute(cargo_fuzz_config, rust_test_workspace)
assert result.status == "success"
assert result.execution_time > 0
Integration Test Example
@pytest.mark.integration
async def test_end_to_end_workflow():
"""Test complete workflow execution"""
# Test full workflow with real services
pass
CI/CD Integration
Tests run automatically on:
- Push to main/develop: Full test suite
- Pull requests: Full test suite + coverage
- Nightly: Extended integration tests
See .github/workflows/test.yml for configuration.
Code Coverage
Target coverage: 80%+ for core modules
View coverage report:
pytest tests/ --cov --cov-report=html
open htmlcov/index.html