Perform comprehensive test analysis.
(self, results_file: Path = None)
| 498 | return recommendations |
| 499 | |
| 500 | def analyze(self, results_file: Path = None) -> TestAnalysisReport: |
| 501 | """Perform comprehensive test analysis.""" |
| 502 | if results_file is None: |
| 503 | results_file = self.project_root / "test_results.json" |
| 504 | |
| 505 | # Store results for historical analysis |
| 506 | self.store_test_results(results_file) |
| 507 | |
| 508 | # Perform analysis |
| 509 | failure_patterns = self.analyze_failure_patterns(results_file) |
| 510 | coverage_gaps = self.analyze_coverage_gaps() |
| 511 | performance_issues = self.analyze_performance_issues(results_file) |
| 512 | flaky_tests = self.identify_flaky_tests() |
| 513 | |
| 514 | # Create report |
| 515 | report = TestAnalysisReport( |
| 516 | timestamp=time.strftime('%Y-%m-%d %H:%M:%S'), |
| 517 | failure_patterns=failure_patterns, |
| 518 | coverage_gaps=coverage_gaps, |
| 519 | performance_issues=performance_issues, |
| 520 | flaky_tests=flaky_tests, |
| 521 | test_health_score=0.0, # Will be calculated |
| 522 | recommendations=[] # Will be generated |
| 523 | ) |
| 524 | |
| 525 | # Calculate health score and recommendations |
| 526 | report.test_health_score = self.calculate_test_health_score(report) |
| 527 | report.recommendations = self.generate_recommendations(report) |
| 528 | |
| 529 | return report |
| 530 | |
| 531 | def format_report(self, report: TestAnalysisReport, format_type: str = "detailed") -> str: |
| 532 | """Format analysis report for different output types.""" |
no test coverage detected