TDD 작성
This commit is contained in:
@@ -4,10 +4,12 @@ import 'package:mockito/annotations.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:lanebow/services/event_service.dart';
|
||||
import 'package:lanebow/services/api_service.dart';
|
||||
import 'package:lanebow/services/event_bus.dart';
|
||||
import 'package:lanebow/models/event_model.dart';
|
||||
import 'package:lanebow/models/participant_model.dart';
|
||||
import 'package:lanebow/models/score_model.dart';
|
||||
import 'package:lanebow/config/api_config.dart';
|
||||
import 'package:lanebow/utils/test_utils.dart';
|
||||
|
||||
// 모킹 클래스 생성
|
||||
@GenerateMocks([ApiService])
|
||||
@@ -61,6 +63,16 @@ void main() {
|
||||
};
|
||||
|
||||
setUp(() async {
|
||||
// 테스트 모드 강제 설정
|
||||
TestUtils.setTestMode(true);
|
||||
|
||||
// 테스트별 고유 ID 생성 및 설정
|
||||
final testId = 'event_service_test_${DateTime.now().millisecondsSinceEpoch}';
|
||||
EventBus.setCurrentTestId(testId);
|
||||
|
||||
// EventBus 완전 초기화
|
||||
EventBus().reset();
|
||||
|
||||
// SharedPreferences 모킹
|
||||
SharedPreferences.setMockInitialValues({
|
||||
ApiConfig.clubIdKey: testClubId,
|
||||
@@ -78,6 +90,20 @@ void main() {
|
||||
// 클럽 ID 설정
|
||||
eventService.setClubId(testClubId);
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
// 테스트 종료 후 EventBus 초기화
|
||||
EventBus().reset();
|
||||
|
||||
// 테스트에서 생성된 EventService 정리
|
||||
eventService.dispose();
|
||||
|
||||
// 테스트 ID 초기화
|
||||
EventBus.clearCurrentTestId();
|
||||
|
||||
// 테스트 모드 해제
|
||||
TestUtils.setTestMode(false);
|
||||
});
|
||||
|
||||
group('EventService 테스트', () {
|
||||
test('initialize 메서드가 토큰을 설정해야 함', () async {
|
||||
|
||||
Reference in New Issue
Block a user