#!/usr/bin/env python3 """ EU-Utility Test Suite Runner Runs all unit, integration, and e2e tests. Usage: python run_all_tests.py """ import sys import os import unittest from pathlib import Path # Add project root to path project_root = Path(__file__).parent.parent sys.path.insert(0, str(project_root)) def discover_and_run_tests(): """Discover and run all tests.""" # Create test suite loader = unittest.TestLoader() suite = unittest.TestSuite() # Test directories test_dirs = [ project_root / "tests" / "unit", project_root / "tests" / "integration", project_root / "tests" / "e2e", ] total_tests = 0 for test_dir in test_dirs: if test_dir.exists(): print(f"Discovering tests in: {test_dir}") discovered = loader.discover(str(test_dir), pattern="test_*.py") suite.addTests(discovered) # Count tests for test_group in discovered: for test_case in test_group: total_tests += test_case.countTestCases() print(f"\nRunning {total_tests} tests...\n") # Run tests with verbose output runner = unittest.TextTestRunner(verbosity=2) result = runner.run(suite) # Print summary print("\n" + "="*70) print("TEST SUMMARY") print("="*70) print(f"Tests Run: {result.testsRun}") print(f"Successes: {result.testsRun - len(result.failures) - len(result.errors)}") print(f"Failures: {len(result.failures)}") print(f"Errors: {len(result.errors)}") print(f"Skipped: {len(result.skipped)}") if result.wasSuccessful(): print("\n✓ All tests passed!") return 0 else: print("\n✗ Some tests failed!") return 1 if __name__ == '__main__': sys.exit(discover_and_run_tests())