Run all soft context swapping tests and provide summary
()
| 464 | |
| 465 | |
| 466 | def run_tests(): |
| 467 | """Run all soft context swapping tests and provide summary""" |
| 468 | print("Soft Context Swapping - Test Suite") |
| 469 | print("=" * 60) |
| 470 | print("Testing the new cookie-based authentication rotation system...") |
| 471 | print("Performance target: <1 second (vs old 3-5 second hard restart)") |
| 472 | print("=" * 60) |
| 473 | |
| 474 | # Create test suite |
| 475 | test_classes = [TestSoftContextSwapping, TestSoftContextSwappingIntegration] |
| 476 | |
| 477 | total_tests = 0 |
| 478 | passed_tests = 0 |
| 479 | |
| 480 | for test_class in test_classes: |
| 481 | print(f"\nRunning {test_class.__name__}...") |
| 482 | suite = unittest.TestLoader().loadTestsFromTestCase(test_class) |
| 483 | result = unittest.TextTestRunner(verbosity=2).run(suite) |
| 484 | |
| 485 | total_tests += result.testsRun |
| 486 | passed_tests += result.testsRun - len(result.failures) - len(result.errors) |
| 487 | |
| 488 | if result.failures: |
| 489 | print(f" ❌ Failures: {len(result.failures)}") |
| 490 | for failure in result.failures: |
| 491 | print(f" - {failure[0]}") |
| 492 | if result.errors: |
| 493 | print(f" 🚨 Errors: {len(result.errors)}") |
| 494 | for error in result.errors: |
| 495 | print(f" - {error[0]}") |
| 496 | |
| 497 | print("\n" + "=" * 60) |
| 498 | print("Test Summary:") |
| 499 | print(f" Total Tests: {total_tests}") |
| 500 | print(f" Passed: {passed_tests}") |
| 501 | print( |
| 502 | f" Success Rate: {(passed_tests / total_tests) * 100:.1f}%" |
| 503 | if total_tests > 0 |
| 504 | else " Success Rate: 0%" |
| 505 | ) |
| 506 | |
| 507 | if passed_tests == total_tests: |
| 508 | print("\n🎉 All tests passed! Soft Context Swapping is working correctly.") |
| 509 | print("✅ Performance improvements validated") |
| 510 | print("✅ Cookie-based rotation confirmed") |
| 511 | print("✅ Browser restart prevention verified") |
| 512 | else: |
| 513 | print( |
| 514 | f"\n⚠️ {total_tests - passed_tests} test(s) failed. Review the implementation." |
| 515 | ) |
| 516 | |
| 517 | return passed_tests == total_tests |
| 518 | |
| 519 | |
| 520 | if __name__ == "__main__": |
no test coverage detected