mirror of
https://github.com/JamesTheGiblet/BuddAI.git
synced 2026-01-08 21:58:40 +00:00
Add comprehensive unit tests for BuddAI functionality
- Introduced 16 additional coverage tests in `test_additional_coverage.py` to enhance overall test coverage. - Added 15 extended feature tests in `test_extended_features.py` to validate new functionalities. - Implemented 27 final coverage tests in `test_final_coverage.py` to achieve a total of 100 tests. - Created 2 fallback logic tests in `test_fallback_logic.py` to ensure proper fallback behavior based on confidence scores. - Each test suite covers various aspects of the BuddAI system, including command handling, database interactions, and hardware detection.
This commit is contained in:
parent
f9fd27d228
commit
27601aa2ba
34 changed files with 5022 additions and 2921 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import unittest
|
||||
import sys
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
def run_suite():
|
||||
"""
|
||||
|
|
@ -9,6 +10,10 @@ def run_suite():
|
|||
# Get directories
|
||||
tests_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
project_root = os.path.dirname(tests_dir)
|
||||
reports_dir = os.path.join(tests_dir, "reports")
|
||||
|
||||
if not os.path.exists(reports_dir):
|
||||
os.makedirs(reports_dir)
|
||||
|
||||
# Add project root to sys.path to allow imports of 'core', 'skills', etc.
|
||||
if project_root not in sys.path:
|
||||
|
|
@ -18,9 +23,32 @@ def run_suite():
|
|||
loader = unittest.TestLoader()
|
||||
suite = loader.discover(tests_dir, pattern="test_*.py", top_level_dir=project_root)
|
||||
|
||||
# Run tests
|
||||
runner = unittest.TextTestRunner(verbosity=2)
|
||||
result = runner.run(suite)
|
||||
# Setup report file
|
||||
timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
|
||||
report_path = os.path.join(reports_dir, f"test_report_{timestamp}.txt")
|
||||
|
||||
print(f"🚀 Running tests... (Logging to {report_path})")
|
||||
|
||||
with open(report_path, "w", encoding="utf-8") as f:
|
||||
f.write(f"BuddAI Test Report\n")
|
||||
f.write(f"Date: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n")
|
||||
f.write("="*60 + "\n\n")
|
||||
|
||||
# Run tests
|
||||
runner = unittest.TextTestRunner(stream=f, verbosity=2)
|
||||
result = runner.run(suite)
|
||||
|
||||
f.write("\n" + "="*60 + "\n")
|
||||
f.write(f"SUMMARY:\n")
|
||||
f.write(f"Ran: {result.testsRun} tests\n")
|
||||
f.write(f"Failures: {len(result.failures)}\n")
|
||||
f.write(f"Errors: {len(result.errors)}\n")
|
||||
|
||||
if result.wasSuccessful():
|
||||
print(f"✅ All {result.testsRun} tests passed!")
|
||||
else:
|
||||
print(f"❌ Tests failed! ({len(result.failures)} failures, {len(result.errors)} errors)")
|
||||
print(f"📝 Check report: {report_path}")
|
||||
|
||||
return result.wasSuccessful()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue