Skip to content

Commit

Permalink
[Test] #362 MountainList 가져오기 Test 코드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
MINRYUL committed Nov 30, 2021
1 parent 896e1ca commit f0290c7
Show file tree
Hide file tree
Showing 7 changed files with 253 additions and 12 deletions.
52 changes: 52 additions & 0 deletions SanTa/MountainListSceneTests/MountainListSceneTests.swift
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)
}
}
4 changes: 2 additions & 2 deletions SanTa/RecordingSceneTests/RecordingUseCaseTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ final class RecordingUseCaseTests: XCTestCase {

func test_음성안내_옵션_False_값_가져오기_성공() {
_ = XCTWaiter.wait(for: [expectation(description: "Wait for 0.5 seconds")], timeout: 0.5)
self.repository.fetchRecordOption(key: Settings.recordPhoto) { result in
self.repository.fetchRecordOption(key: Settings.mapFormat) { result in
switch result {
case .failure:
return
Expand All @@ -82,7 +82,7 @@ final class RecordingUseCaseTests: XCTestCase {

func test_사진저장_옵션_False_값_가져오기_성공() {
_ = XCTWaiter.wait(for: [expectation(description: "Wait for 0.5 seconds")], timeout: 0.5)
self.repository.fetchRecordOption(key: Settings.recordPhoto) { result in
self.repository.fetchRecordOption(key: Settings.mapFormat) { result in
switch result {
case .failure:
return
Expand Down
137 changes: 137 additions & 0 deletions SanTa/SanTa.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@
98BCF4F72737A66E0073E6FB /* SettingsUsecase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98BCF4F62737A66E0073E6FB /* SettingsUsecase.swift */; };
98BCF4F92737A7120073E6FB /* SettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98BCF4F82737A7120073E6FB /* SettingsViewModel.swift */; };
DA4736D22755E39500841326 /* Location.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA4736D12755E39500841326 /* Location.swift */; };
DA4736E6275610EE00841326 /* Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9826F3DE273904010064FA85 /* Settings.swift */; };
DA4736E7275610F600841326 /* Record.swift in Sources */ = {isa = PBXBuildFile; fileRef = 984DDEC027325D67003BE56B /* Record.swift */; };
DA4736E8275610FA00841326 /* Location.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA4736D12755E39500841326 /* Location.swift */; };
DA4736F327561C6200841326 /* MountainListSceneTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA4736F227561C6200841326 /* MountainListSceneTests.swift */; };
DA4736F927561C9400841326 /* MountainListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAAF4D6B273CE02400780DC8 /* MountainListViewModel.swift */; };
DA4736FA27561C9400841326 /* MountainListViewUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAAF4D6D273CE06A00780DC8 /* MountainListViewUseCase.swift */; };
DA4736FB27561C9A00841326 /* MountainEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49FEEDB82732584000D37CCA /* MountainEntity.swift */; };
DA854FD42746270A00E51E4B /* UserDefaultsStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98A913002736844E008AAE39 /* UserDefaultsStorage.swift */; };
DA854FDC2746273300E51E4B /* RecordingUseCaseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA854FDB2746273300E51E4B /* RecordingUseCaseTests.swift */; };
DA854FE02746279F00E51E4B /* RecordingUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 984DDEC227325DFC003BE56B /* RecordingUseCase.swift */; };
Expand Down Expand Up @@ -128,6 +135,13 @@
remoteGlobalIDString = 5485127D272A6AD500407F28;
remoteInfo = SanTa;
};
DA4736F427561C6200841326 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 54851276272A6AD500407F28 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 5485127D272A6AD500407F28;
remoteInfo = SanTa;
};
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -209,6 +223,8 @@
98BCF4F62737A66E0073E6FB /* SettingsUsecase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsUsecase.swift; sourceTree = "<group>"; };
98BCF4F82737A7120073E6FB /* SettingsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewModel.swift; sourceTree = "<group>"; };
DA4736D12755E39500841326 /* Location.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Location.swift; sourceTree = "<group>"; };
DA4736F027561C6200841326 /* MountainListSceneTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MountainListSceneTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
DA4736F227561C6200841326 /* MountainListSceneTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MountainListSceneTests.swift; sourceTree = "<group>"; };
DA854FD92746273300E51E4B /* RecordingSceneTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RecordingSceneTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
DA854FDB2746273300E51E4B /* RecordingUseCaseTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecordingUseCaseTests.swift; sourceTree = "<group>"; };
DA9D7C9C273A433E0018AD45 /* RecordingTitleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecordingTitleViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -254,6 +270,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
DA4736ED27561C6200841326 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
DA854FD62746273300E51E4B /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -423,6 +446,7 @@
9826F42E273953FB0064FA85 /* SettingsSceneTests */,
DA854FDA2746273300E51E4B /* RecordingSceneTests */,
98BAABB2275479B0004505BB /* ResultSceneTests */,
DA4736F127561C6200841326 /* MountainListSceneTests */,
5485127F272A6AD500407F28 /* Products */,
);
sourceTree = "<group>";
Expand All @@ -434,6 +458,7 @@
9826F42D273953FB0064FA85 /* SettingsSceneTests.xctest */,
DA854FD92746273300E51E4B /* RecordingSceneTests.xctest */,
98BAABB1275479B0004505BB /* ResultSceneTests.xctest */,
DA4736F027561C6200841326 /* MountainListSceneTests.xctest */,
);
name = Products;
sourceTree = "<group>";
Expand Down Expand Up @@ -507,6 +532,14 @@
path = Scenes;
sourceTree = "<group>";
};
DA4736F127561C6200841326 /* MountainListSceneTests */ = {
isa = PBXGroup;
children = (
DA4736F227561C6200841326 /* MountainListSceneTests.swift */,
);
path = MountainListSceneTests;
sourceTree = "<group>";
};
DA854FDA2746273300E51E4B /* RecordingSceneTests */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -609,6 +642,24 @@
productReference = 98BAABB1275479B0004505BB /* ResultSceneTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
DA4736EF27561C6200841326 /* MountainListSceneTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = DA4736F627561C6200841326 /* Build configuration list for PBXNativeTarget "MountainListSceneTests" */;
buildPhases = (
DA4736EC27561C6200841326 /* Sources */,
DA4736ED27561C6200841326 /* Frameworks */,
DA4736EE27561C6200841326 /* Resources */,
);
buildRules = (
);
dependencies = (
DA4736F527561C6200841326 /* PBXTargetDependency */,
);
name = MountainListSceneTests;
productName = MountainListSceneTestss;
productReference = DA4736F027561C6200841326 /* MountainListSceneTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
DA854FD82746273300E51E4B /* RecordingSceneTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = DA854FDD2746273300E51E4B /* Build configuration list for PBXNativeTarget "RecordingSceneTests" */;
Expand Down Expand Up @@ -647,6 +698,10 @@
CreatedOnToolsVersion = 13.0;
TestTargetID = 5485127D272A6AD500407F28;
};
DA4736EF27561C6200841326 = {
CreatedOnToolsVersion = 13.0;
TestTargetID = 5485127D272A6AD500407F28;
};
DA854FD82746273300E51E4B = {
CreatedOnToolsVersion = 13.0;
};
Expand All @@ -669,6 +724,7 @@
9826F42C273953FB0064FA85 /* SettingsSceneTests */,
DA854FD82746273300E51E4B /* RecordingSceneTests */,
98BAABB0275479B0004505BB /* ResultSceneTests */,
DA4736EF27561C6200841326 /* MountainListSceneTests */,
);
};
/* End PBXProject section */
Expand Down Expand Up @@ -698,6 +754,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
DA4736EE27561C6200841326 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
DA854FD72746273300E51E4B /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -824,10 +887,24 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
DA4736EC27561C6200841326 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DA4736FB27561C9A00841326 /* MountainEntity.swift in Sources */,
DA4736F927561C9400841326 /* MountainListViewModel.swift in Sources */,
DA4736FA27561C9400841326 /* MountainListViewUseCase.swift in Sources */,
DA4736F327561C6200841326 /* MountainListSceneTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
DA854FD52746273300E51E4B /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DA4736E8275610FA00841326 /* Location.swift in Sources */,
DA4736E7275610F600841326 /* Record.swift in Sources */,
DA4736E6275610EE00841326 /* Settings.swift in Sources */,
DA854FE92746292300E51E4B /* RecordingViewModel.swift in Sources */,
DA854FE62746282600E51E4B /* RecordingPhotoModel.swift in Sources */,
DAB25F1B2754AF2D00F0BE75 /* RecordingViewModelTests.swift in Sources */,
Expand All @@ -850,6 +927,11 @@
target = 5485127D272A6AD500407F28 /* SanTa */;
targetProxy = 98BAABB5275479B0004505BB /* PBXContainerItemProxy */;
};
DA4736F527561C6200841326 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 5485127D272A6AD500407F28 /* SanTa */;
targetProxy = DA4736F427561C6200841326 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */

/* Begin PBXVariantGroup section */
Expand Down Expand Up @@ -1134,6 +1216,52 @@
};
name = Release;
};
DA4736F727561C6200841326 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = GQ4HM48H8H;
GENERATE_INFOPLIST_FILE = YES;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = ajou.minryul.MountainListSceneTestss;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SanTa.app/SanTa";
};
name = Debug;
};
DA4736F827561C6200841326 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = GQ4HM48H8H;
GENERATE_INFOPLIST_FILE = YES;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = ajou.minryul.MountainListSceneTestss;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SanTa.app/SanTa";
};
name = Release;
};
DA854FDE2746273300E51E4B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
Expand Down Expand Up @@ -1215,6 +1343,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
DA4736F627561C6200841326 /* Build configuration list for PBXNativeTarget "MountainListSceneTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
DA4736F727561C6200841326 /* Debug */,
DA4736F827561C6200841326 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
DA854FDD2746273300E51E4B /* Build configuration list for PBXNativeTarget "RecordingSceneTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
Expand Down
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>
12 changes: 6 additions & 6 deletions SanTa/SanTa.xcodeproj/xcshareddata/xcschemes/SanTa.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DA854FC22746176A00E51E4B"
BuildableName = "RecordingSceneTest.xctest"
BlueprintName = "RecordingSceneTest"
BlueprintIdentifier = "98BAABB0275479B0004505BB"
BuildableName = "ResultSceneTests.xctest"
BlueprintName = "ResultSceneTests"
ReferencedContainer = "container:SanTa.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "98BAABB0275479B0004505BB"
BuildableName = "ResultSceneTests.xctest"
BlueprintName = "ResultSceneTests"
BlueprintIdentifier = "DA4736EF27561C6200841326"
BuildableName = "MountainListSceneTestss.xctest"
BlueprintName = "MountainListSceneTests"
ReferencedContainer = "container:SanTa.xcodeproj">
</BuildableReference>
</TestableReference>
Expand Down
Loading

0 comments on commit f0290c7

Please sign in to comment.