Files
superport/test/integration/automated/test_result.dart
JiWoong Sul c8dd1ff815
Some checks failed
Flutter Test & Quality Check / Test on macos-latest (push) Has been cancelled
Flutter Test & Quality Check / Test on ubuntu-latest (push) Has been cancelled
Flutter Test & Quality Check / Build APK (push) Has been cancelled
refactor: 프로젝트 구조 개선 및 테스트 시스템 강화
주요 변경사항:
- CLAUDE.md: 프로젝트 규칙 v2.0으로 업데이트, 아키텍처 명확화
- 불필요한 문서 제거: NEXT_TASKS.md, TEST_PROGRESS.md, test_results 파일들
- 테스트 시스템 개선: 실제 API 테스트 스위트 추가 (15개 새 테스트 파일)
- License 관리: DTO 모델 개선, API 응답 처리 최적화
- 에러 처리: Interceptor 로직 강화, 상세 로깅 추가
- Company/User/Warehouse 테스트: 자동화 테스트 안정성 향상
- Phone Utils: 전화번호 포맷팅 로직 개선
- Overview Controller: 대시보드 데이터 로딩 최적화
- Analysis Options: Flutter 린트 규칙 추가

테스트 개선:
- company_real_api_test.dart: 실제 API 회사 관리 테스트
- equipment_in/out_real_api_test.dart: 장비 입출고 API 테스트
- license_real_api_test.dart: 라이선스 관리 API 테스트
- user_real_api_test.dart: 사용자 관리 API 테스트
- warehouse_location_real_api_test.dart: 창고 위치 API 테스트
- filter_sort_test.dart: 필터링/정렬 기능 테스트
- pagination_test.dart: 페이지네이션 테스트
- interactive_search_test.dart: 검색 기능 테스트
- overview_dashboard_test.dart: 대시보드 통합 테스트

코드 품질:
- 모든 서비스에 에러 처리 강화
- DTO 모델 null safety 개선
- 테스트 커버리지 확대
- 불필요한 로그 파일 제거로 리포지토리 정리

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-07 17:16:30 +09:00

107 lines
3.3 KiB
Dart

/// 테스트 실행 결과를 담는 클래스
class TestResult {
final String name;
final int totalTests;
final int passedTests;
final int failedTests;
final List<String> failedTestNames;
final Duration executionTime;
final Map<String, dynamic> metadata;
TestResult({
required this.name,
required this.totalTests,
required this.passedTests,
required this.failedTests,
this.failedTestNames = const [],
required this.executionTime,
this.metadata = const {},
});
double get passRate => totalTests > 0 ? (passedTests / totalTests) * 100 : 0;
bool get isSuccess => failedTests == 0;
String get summary {
final emoji = isSuccess ? '' : '';
return '$emoji $name: $passedTests/$totalTests 통과 (${passRate.toStringAsFixed(1)}%)';
}
Map<String, dynamic> toJson() => {
'name': name,
'totalTests': totalTests,
'passedTests': passedTests,
'failedTests': failedTests,
'failedTestNames': failedTestNames,
'executionTimeMs': executionTime.inMilliseconds,
'passRate': passRate,
'metadata': metadata,
};
}
/// 전체 테스트 스위트 결과
class TestSuiteResult {
final List<TestResult> results;
final DateTime timestamp;
TestSuiteResult({
required this.results,
DateTime? timestamp,
}) : timestamp = timestamp ?? DateTime.now();
int get totalTests => results.fold(0, (sum, r) => sum + r.totalTests);
int get passedTests => results.fold(0, (sum, r) => sum + r.passedTests);
int get failedTests => results.fold(0, (sum, r) => sum + r.failedTests);
double get overallPassRate => totalTests > 0 ? (passedTests / totalTests) * 100 : 0;
bool get isSuccess => failedTests == 0;
Duration get totalExecutionTime => Duration(
milliseconds: results.fold(0, (sum, r) => sum + r.executionTime.inMilliseconds),
);
String get summary {
final buffer = StringBuffer();
buffer.writeln('\n' + '=' * 60);
buffer.writeln('📊 테스트 실행 결과 요약');
buffer.writeln('=' * 60);
buffer.writeln('실행 시간: ${timestamp.toLocal()}');
buffer.writeln('총 실행 시간: ${totalExecutionTime.inSeconds}');
buffer.writeln('');
for (final result in results) {
buffer.writeln(result.summary);
}
buffer.writeln('');
buffer.writeln('-' * 60);
buffer.writeln('전체 결과: $passedTests/$totalTests 통과 (${overallPassRate.toStringAsFixed(1)}%)');
if (isSuccess) {
buffer.writeln('🎉 모든 테스트가 성공적으로 통과했습니다!');
} else {
buffer.writeln('⚠️ 실패한 테스트가 있습니다.');
buffer.writeln('\n실패한 테스트 목록:');
for (final result in results) {
if (result.failedTestNames.isNotEmpty) {
buffer.writeln('\n${result.name}:');
for (final testName in result.failedTestNames) {
buffer.writeln(' - $testName');
}
}
}
}
buffer.writeln('=' * 60);
return buffer.toString();
}
Map<String, dynamic> toJson() => {
'timestamp': timestamp.toIso8601String(),
'totalTests': totalTests,
'passedTests': passedTests,
'failedTests': failedTests,
'overallPassRate': overallPassRate,
'totalExecutionTimeMs': totalExecutionTime.inMilliseconds,
'results': results.map((r) => r.toJson()).toList(),
};
}