Files
superport/test/integration/automated/test_result.dart
JiWoong Sul 731dcd816b
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: Repository 패턴 적용 및 Clean Architecture 완성
## 주요 변경사항

### 🏗️ Architecture
- Repository 패턴 전면 도입 (인터페이스/구현체 분리)
- Domain Layer에 Repository 인터페이스 정의
- Data Layer에 Repository 구현체 배치
- UseCase 의존성을 Service에서 Repository로 전환

### 📦 Dependency Injection
- GetIt 기반 DI Container 재구성 (lib/injection_container.dart)
- Repository 인터페이스와 구현체 등록
- Service와 Repository 공존 (마이그레이션 기간)

### 🔄 Migration Status
완료:
- License 모듈 (6개 UseCase)
- Warehouse Location 모듈 (5개 UseCase)

진행중:
- Auth 모듈 (2/5 UseCase)
- Company 모듈 (1/6 UseCase)

대기:
- User 모듈 (7개 UseCase)
- Equipment 모듈 (4개 UseCase)

### 🎯 Controller 통합
- 중복 Controller 제거 (with_usecase 버전)
- 단일 Controller로 통합
- UseCase 패턴 직접 적용

### 🧹 코드 정리
- 임시 파일 제거 (test_*.md, task.md)
- Node.js 아티팩트 제거 (package.json)
- 불필요한 테스트 파일 정리

###  테스트 개선
- Real API 중심 테스트 구조
- Mock 제거, 실제 API 엔드포인트 사용
- 통합 테스트 프레임워크 강화

## 기술적 영향
- 의존성 역전 원칙 적용
- 레이어 간 결합도 감소
- 테스트 용이성 향상
- 확장성 및 유지보수성 개선

## 다음 단계
1. User/Equipment 모듈 Repository 마이그레이션
2. Service Layer 점진적 제거
3. 캐싱 전략 구현
4. 성능 최적화
2025-08-11 20:14:10 +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(),
};
}