""" 批量运行所有测试 """ import unittest import sys import os sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) def run_unit_tests(): """运行单元测试""" print("=== 运行单元测试 ===") loader = unittest.TestLoader() suite = loader.discover('tests/unit', pattern='test_*.py') runner = unittest.TextTestRunner(verbosity=2) result = runner.run(suite) return result.wasSuccessful() def run_integration_tests(): """运行集成测试""" print("\n=== 运行集成测试 ===") loader = unittest.TestLoader() suite = loader.discover('tests/integration', pattern='test_*.py') runner = unittest.TextTestRunner(verbosity=2) result = runner.run(suite) return result.wasSuccessful() def run_all_tests(): """运行所有测试""" print("Human-Clone 系统测试套件") print("=" * 50) unit_success = run_unit_tests() integration_success = run_integration_tests() print("\n=== 测试结果汇总 ===") print(f"单元测试: {'✓ 通过' if unit_success else '✗ 失败'}") print(f"集成测试: {'✓ 通过' if integration_success else '✗ 失败'}") if unit_success and integration_success: print("🎉 所有测试通过!") return True else: print("❌ 存在测试失败") return False if __name__ == "__main__": success = run_all_tests() sys.exit(0 if success else 1)