Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IDLE] 모킹 객체를 관리하는 Testing 모듈 구현 및 적용 #89

Merged
merged 10 commits into from
Oct 16, 2024

Conversation

J0onYEong
Copy link
Contributor

변경된 점

  • 모킹 객체를 관리하는 Testing 모듈 구현 및 적용

모킹 객체를 관리하는 Testing 모듈 구현 및 적용

Unit테스트는 백엔드 통신에 대한 의존을 최소화 하고 어플리케이션 자체 로직에 대한 동작여부를 테스트 해야한다.
따라서 필요로 하는 객체애대한 모킹 객체를 주입하여 유닛 테스트를 진행하도록 모듈구조를 변경했다.

struct MockDataAssembly: Assembly {
    
    func assemble(container: Container) {
        container.register(AuthInputValidationRepository.self) { _ in
            MockAuthInputValidationRepository()
        }
        
        container.register(KeyValueStore.self) { _ in
            TestKeyValueStore()
        }
        
        container.register(LocalStorageService.self) { _ in
            MockLocalStorageService()
        }
    }
}

예를들어 UseCase를 테스트하는 경우 Testing객체로부터 모킹된 Data객체들을 전달받을 수 있다.

final class RegisterValidationTests: XCTestCase {
    
    static override func setUp() {
        DependencyInjector.shared.assemble(MockAssemblies)
    }

...

테스트코드의 setUp함수에 의존성 주입을 진행함으로써 모킹 객체를 사용할 수 있다.

의존성 다이어그램

추후 ViewModel테스트시에도 모킹객체를 활용할 수 있도록 아래 그림과 같은 모듈구조를 가질 예정이다.
image

@J0onYEong J0onYEong merged commit 124588c into develop Oct 16, 2024
1 check passed
@J0onYEong J0onYEong deleted the refactor/Testing branch October 16, 2024 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant