Files
superport/test/integration/automated/README_EQUIPMENT_IN_TEST.md
JiWoong Sul 198aac6525
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
test: 통합 테스트 오류 및 경고 수정
- 모든 서비스 메서드 시그니처를 실제 구현에 맞게 수정
- TestDataGenerator 제거하고 직접 객체 생성으로 변경
- 모델 필드명 및 타입 불일치 수정
- 불필요한 Either 패턴 사용 제거
- null safety 관련 이슈 해결

수정된 파일:
- test/integration/screens/company_integration_test.dart
- test/integration/screens/equipment_integration_test.dart
- test/integration/screens/user_integration_test.dart
- test/integration/screens/login_integration_test.dart
2025-08-05 20:24:05 +09:00

3.8 KiB

장비 입고 자동화 테스트

개요

이 테스트는 장비 입고 전체 프로세스를 자동으로 실행하고, 에러 발생 시 자동으로 진단하고 수정합니다.

주요 기능

1. 자동 데이터 생성

  • 필요한 회사, 창고를 자동으로 생성
  • 장비 정보를 자동으로 입력 (제조사, 모델명, 시리얼번호 등)
  • 카테고리 자동 선택

2. 입고 프로세스 실행

  • 장비 생성 API 호출 (/equipment POST)
  • 장비 입고 이력 추가 (/equipment/{id}/history POST)
  • 상태 확인 및 검증

3. 에러 자동 처리

  • API 에러 발생시 자동 진단
  • 누락된 필드 자동 추가
  • 타입 불일치 자동 수정
  • 참조 데이터 누락시 자동 생성
  • 재시도 로직

4. 테스트 시나리오

  1. 정상 입고: 모든 데이터가 올바른 경우
  2. 필수 필드 누락: 제조사, 카테고리 등 필수 필드가 없는 경우
  3. 잘못된 참조 ID: 존재하지 않는 회사/창고 ID 사용
  4. 중복 시리얼 번호: 이미 존재하는 시리얼 번호로 장비 생성
  5. 권한 오류: 접근 권한이 없는 창고에 입고 시도

실행 방법

1. 전체 테스트 실행

flutter test test/integration/automated/run_equipment_in_test.dart

2. 특정 시나리오만 실행

flutter test test/integration/automated/run_equipment_in_test.dart --name "정상 입고"

3. 상세 로그 출력

flutter test test/integration/automated/run_equipment_in_test.dart --verbose

테스트 결과

테스트 실행 시 다음 정보가 출력됩니다:

  1. 각 단계별 진행 상황

    • 회사/창고 생성
    • 장비 데이터 생성
    • API 호출 및 응답
    • 에러 발생 및 수정 과정
  2. 에러 진단 정보

    • 에러 타입 (필드 누락, 타입 불일치, 참조 오류 등)
    • 자동 수정 방법
    • 재시도 결과
  3. 최종 결과

    • 성공/실패 테스트 수
    • 자동 수정된 항목 목록
    • 실행 시간

주요 구현 내용

EquipmentInAutomatedTest 클래스

  • performNormalEquipmentIn(): 정상 입고 프로세스 실행
  • performEquipmentInWithMissingFields(): 필수 필드 누락 시나리오
  • performEquipmentInWithInvalidReferences(): 잘못된 참조 시나리오
  • performEquipmentInWithDuplicateSerial(): 중복 시리얼 시나리오
  • performEquipmentInWithPermissionError(): 권한 오류 시나리오

자동 수정 프로세스

  1. 에러 발생 감지
  2. ApiErrorDiagnostics를 통한 에러 진단
  3. AutoFixer를 통한 데이터 자동 수정
  4. TestDataGenerator를 통한 필요 데이터 생성
  5. 수정된 데이터로 재시도

사용 예시

// 정상 입고 프로세스
final equipment = Equipment(
  manufacturer: '삼성전자',
  name: 'EQ-AUTO-12345',
  category: '노트북',
  serialNumber: 'SN-2024-123456',
  quantity: 1,
);

final createdEquipment = await equipmentService.createEquipment(equipment);

// 입고 처리
await equipmentService.equipmentIn(
  equipmentId: createdEquipment.id,
  quantity: 1,
  warehouseLocationId: warehouseId,
  notes: '자동 테스트 입고',
);

에러 처리 예시

// 필수 필드 누락 시
try {
  await equipmentService.createEquipment(incompleteEquipment);
} catch (e) {
  // 에러 진단
  final diagnosis = await errorDiagnostics.diagnoseError(apiError);
  
  // 자동 수정
  final fixedData = await autoFixer.fixData(data, diagnosis);
  
  // 재시도
  await equipmentService.createEquipment(fixedData);
}

주의사항

  1. 테스트 실행 전 API 서버가 실행 중이어야 합니다.
  2. 테스트 계정 정보가 올바르게 설정되어 있어야 합니다.
  3. 테스트 데이터는 자동으로 생성되고 정리됩니다.
  4. 실제 운영 환경에서는 실행하지 마세요.