-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Test] #362 MountainList 가져오기 Test 코드 추가
- Loading branch information
Showing
7 changed files
with
253 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// MountainListSceneTestss.swift | ||
// MountainListSceneTestss | ||
// | ||
// Created by 김민창 on 2021/11/30. | ||
// | ||
|
||
import XCTest | ||
|
||
final class MountainListSceneTests: XCTestCase { | ||
|
||
private var successUseCase: MountainListUseCase! | ||
private var failUseCase: MountainListUseCase! | ||
private var successViewModel: MountainListViewModel! | ||
private var failViewModel: MountainListViewModel! | ||
|
||
enum TestError: Error { | ||
case error | ||
} | ||
|
||
class SuccessMountainViewRepository: MountainListViewRepository { | ||
func fetchMountains(completion: @escaping (Result<[MountainEntity], Error>) -> Void) { | ||
let mountainList = [MountainEntity]() | ||
completion(.success(mountainList)) | ||
} | ||
} | ||
|
||
class FailMountainViewRepository: MountainListViewRepository { | ||
func fetchMountains(completion: @escaping (Result<[MountainEntity], Error>) -> Void) { | ||
completion(.failure(TestError.error)) | ||
} | ||
} | ||
|
||
override func setUp() { | ||
self.successUseCase = MountainListUseCase(repository: SuccessMountainViewRepository()) | ||
self.failUseCase = MountainListUseCase(repository: FailMountainViewRepository()) | ||
self.successViewModel = MountainListViewModel(useCase: successUseCase) | ||
self.failViewModel = MountainListViewModel(useCase: failUseCase) | ||
} | ||
|
||
func test_MountainList_가져오기_성공 () { | ||
successViewModel.viewDidLoad() | ||
_ = XCTWaiter.wait(for: [expectation(description: "Wait for 0.1 seconds")], timeout: 0.1) | ||
XCTAssertNotNil(successViewModel.mountains) | ||
} | ||
|
||
func test_MountainList_가져오기_실패 () { | ||
failViewModel.viewDidLoad() | ||
_ = XCTWaiter.wait(for: [expectation(description: "Wait for 0.1 seconds")], timeout: 0.1) | ||
XCTAssertNil(failViewModel.mountains) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
SanTa/SanTa.xcodeproj/xcshareddata/xcschemes/MountainListSceneTests.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "1300" | ||
version = "1.3"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES"> | ||
<Testables> | ||
<TestableReference | ||
skipped = "NO"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "DA4736EF27561C6200841326" | ||
BuildableName = "MountainListSceneTests.xctest" | ||
BlueprintName = "MountainListSceneTests" | ||
ReferencedContainer = "container:SanTa.xcodeproj"> | ||
</BuildableReference> | ||
</TestableReference> | ||
</Testables> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.