Add quick test runner and enhance run_tests script
Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled
Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled
- Introduced `quick_test.py` for running specific test categories (unit, integration, theme, all). - Updated `run_tests.py` to improve test execution and reporting, including coverage. - Removed outdated test scripts for keyboard shortcuts, menu theming, note saving, and entry updating. - Added new test script `test_theme_changing.py` to verify theme changing functionality. - Consolidated integration tests into `test_integration.py` for comprehensive testing of TheChart application. - Updated theme manager to ensure color retrieval works correctly. - Modified test constants to import from the correct module path.
This commit is contained in:
@@ -1,25 +1,19 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test runner script for TheChart application.
|
||||
Consolidated test runner script for TheChart application.
|
||||
Run this script to execute all tests with coverage reporting.
|
||||
"""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def run_tests():
|
||||
"""Run all tests with coverage reporting."""
|
||||
def run_unit_tests():
|
||||
"""Run unit tests with coverage reporting."""
|
||||
print("Running unit tests with coverage...")
|
||||
|
||||
# Change to project root directory
|
||||
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
os.chdir(project_root)
|
||||
|
||||
print("Running TheChart tests with coverage...")
|
||||
print(f"Project root: {project_root}")
|
||||
|
||||
# Run pytest with coverage
|
||||
cmd = [
|
||||
sys.executable,
|
||||
"-m",
|
||||
@@ -30,16 +24,106 @@ def run_tests():
|
||||
"--cov-report=term-missing",
|
||||
"--cov-report=html:htmlcov",
|
||||
"--cov-report=xml",
|
||||
"-x", # Stop on first failure for faster feedback
|
||||
]
|
||||
|
||||
try:
|
||||
result = subprocess.run(cmd, check=False)
|
||||
return result.returncode
|
||||
return result.returncode == 0
|
||||
except Exception as e:
|
||||
print(f"Error running tests: {e}")
|
||||
print(f"Error running unit tests: {e}")
|
||||
return False
|
||||
|
||||
|
||||
def run_integration_tests():
|
||||
"""Run integration tests."""
|
||||
print("Running integration tests...")
|
||||
|
||||
cmd = [
|
||||
sys.executable,
|
||||
"-m",
|
||||
"pytest",
|
||||
"tests/test_integration.py",
|
||||
"--verbose",
|
||||
"-s", # Don't capture output so we can see print statements
|
||||
]
|
||||
|
||||
try:
|
||||
result = subprocess.run(cmd, check=False)
|
||||
return result.returncode == 0
|
||||
except Exception as e:
|
||||
print(f"Error running integration tests: {e}")
|
||||
return False
|
||||
|
||||
|
||||
def run_legacy_integration_test():
|
||||
"""Run the legacy integration test for backwards compatibility."""
|
||||
print("Running legacy export integration test...")
|
||||
|
||||
try:
|
||||
# Import and run the integration test directly
|
||||
sys.path.insert(0, "scripts")
|
||||
from integration_test import test_integration
|
||||
|
||||
success = test_integration()
|
||||
return success
|
||||
except Exception as e:
|
||||
print(f"Error running legacy integration test: {e}")
|
||||
return False
|
||||
|
||||
|
||||
def run_all_tests():
|
||||
"""Run all tests in sequence."""
|
||||
project_root = Path(__file__).parent.parent
|
||||
os.chdir(project_root)
|
||||
|
||||
print("TheChart Consolidated Test Suite")
|
||||
print("=" * 40)
|
||||
print(f"Project root: {project_root}")
|
||||
print()
|
||||
|
||||
results = []
|
||||
|
||||
# Run unit tests
|
||||
print("1. Unit Tests")
|
||||
print("-" * 20)
|
||||
unit_success = run_unit_tests()
|
||||
results.append(("Unit Tests", unit_success))
|
||||
print()
|
||||
|
||||
# Run integration tests
|
||||
print("2. Integration Tests")
|
||||
print("-" * 20)
|
||||
integration_success = run_integration_tests()
|
||||
results.append(("Integration Tests", integration_success))
|
||||
print()
|
||||
|
||||
# Run legacy integration test
|
||||
print("3. Legacy Export Integration Test")
|
||||
print("-" * 35)
|
||||
legacy_success = run_legacy_integration_test()
|
||||
results.append(("Legacy Integration", legacy_success))
|
||||
print()
|
||||
|
||||
# Summary
|
||||
print("Test Results Summary")
|
||||
print("=" * 20)
|
||||
all_passed = True
|
||||
for test_name, success in results:
|
||||
status = "✓ PASS" if success else "✗ FAIL"
|
||||
print(f"{test_name:.<25} {status}")
|
||||
if not success:
|
||||
all_passed = False
|
||||
|
||||
print()
|
||||
if all_passed:
|
||||
print("🎉 All tests passed!")
|
||||
return 0
|
||||
else:
|
||||
print("❌ Some tests failed!")
|
||||
return 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
exit_code = run_tests()
|
||||
exit_code = run_all_tests()
|
||||
sys.exit(exit_code)
|
||||
|
||||
Reference in New Issue
Block a user