From f861b21186682da25045d06bba3ddb1defff108d Mon Sep 17 00:00:00 2001 From: kimscastle Date: Fri, 1 Dec 2023 09:44:27 +0900 Subject: [PATCH 01/16] =?UTF-8?q?[ADD]=20challenge=20api=20=EC=84=B1?= =?UTF-8?q?=EA=B3=B5=20json=ED=8C=8C=EC=9D=BC=20=EC=B6=94=EA=B0=80(#198)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 108 +++++++----------- .../xcschemes/LionHeart-iOS.xcscheme | 11 +- LionHeart-iOS/LionHeart-iOS.xctestplan | 38 ++++++ .../ChallengeJSON/ChallengeSuccess.json | 14 +++ .../Challenge/ServiceTests/ServiceTests.swift | 46 +++++--- .../LionHeart_iOSTests.swift | 36 ------ 6 files changed, 130 insertions(+), 123 deletions(-) create mode 100644 LionHeart-iOS/LionHeart-iOS.xctestplan create mode 100644 LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeJSON/ChallengeSuccess.json delete mode 100644 LionHeart-iOS/LionHeart-iOSTests/LionHeart_iOSTests.swift diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index 1f0c8bac..9039a1f5 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -192,12 +192,12 @@ C034EDD82ADE21D200AD6FF3 /* SplashAdaptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = C034EDD72ADE21D200AD6FF3 /* SplashAdaptor.swift */; }; C034EDDA2ADE2A0E00AD6FF3 /* AuthCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C034EDD92ADE2A0E00AD6FF3 /* AuthCoordinator.swift */; }; C034EDDC2ADE2A2C00AD6FF3 /* AuthAdaptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = C034EDDB2ADE2A2C00AD6FF3 /* AuthAdaptor.swift */; }; - C034EDE02ADE3A4A00AD6FF3 /* LionHeart_iOSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B532E8482A5525C800F0DB19 /* LionHeart_iOSTests.swift */; }; C034EE1E2ADE44E200AD6FF3 /* ArticleCategoryAdaptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = C034EE1D2ADE44E200AD6FF3 /* ArticleCategoryAdaptor.swift */; }; C034EE202ADE450600AD6FF3 /* ArticleCategoryCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C034EE1F2ADE450600AD6FF3 /* ArticleCategoryCoordinator.swift */; }; C03FCD422B0DD11C00C4EA0D /* UITabbarItem+.swift in Sources */ = {isa = PBXBuildFile; fileRef = C03FCD412B0DD11C00C4EA0D /* UITabbarItem+.swift */; }; C04BE3AD2ADD4F5D001967B5 /* TodayCoordinatorImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04BE3AC2ADD4F5D001967B5 /* TodayCoordinatorImpl.swift */; }; C04BE3AF2ADD4F7F001967B5 /* TodayAdaptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04BE3AE2ADD4F7F001967B5 /* TodayAdaptor.swift */; }; + C060EAF82B195F1E00AB2855 /* FirebaseMessaging in Frameworks */ = {isa = PBXBuildFile; productRef = C060EAF72B195F1E00AB2855 /* FirebaseMessaging */; }; C06318082B10623000DE1995 /* ChallengeViewDiffableModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C06318072B10623000DE1995 /* ChallengeViewDiffableModel.swift */; }; C06318142B1064C400DE1995 /* ArticleDataByWeek.swift in Sources */ = {isa = PBXBuildFile; fileRef = C06318132B1064C400DE1995 /* ArticleDataByWeek.swift */; }; C063181A2B10658400DE1995 /* ArticleDetailSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = C06318192B10658400DE1995 /* ArticleDetailSection.swift */; }; @@ -324,6 +324,7 @@ C0F029EA2A5FD32900E0D185 /* LHRoundButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0F029E92A5FD32900E0D185 /* LHRoundButton.swift */; }; C0F62FCA2A67CDCE0003ADFA /* BookmarkDetailCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A8980C12A5FD6AF00746C58 /* BookmarkDetailCollectionViewCell.swift */; }; C0F62FE72A691FC40003ADFA /* LHLoadingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0F62FE62A691FC40003ADFA /* LHLoadingView.swift */; }; + C0FF46BC2B1963D300D487D7 /* ChallengeSuccess.json in Resources */ = {isa = PBXBuildFile; fileRef = C0FF46BB2B1963D300D487D7 /* ChallengeSuccess.json */; }; D34280772A66B90C00DA1499 /* UILabelPadding.swift in Sources */ = {isa = PBXBuildFile; fileRef = D34280762A66B90C00DA1499 /* UILabelPadding.swift */; }; D342807A2A67F12200DA1499 /* ChallengeDataResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = D34280792A67F12200DA1499 /* ChallengeDataResponse.swift */; }; D35272D12A681E13002D7FCB /* ChallengeData.swift in Sources */ = {isa = PBXBuildFile; fileRef = D35272D02A681E13002D7FCB /* ChallengeData.swift */; }; @@ -431,7 +432,6 @@ B532E83D2A5525C700F0DB19 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; B532E83F2A5525C700F0DB19 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; B532E8442A5525C800F0DB19 /* LionHeart-iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "LionHeart-iOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; - B532E8482A5525C800F0DB19 /* LionHeart_iOSTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LionHeart_iOSTests.swift; sourceTree = ""; }; B532E84E2A5525C800F0DB19 /* LionHeart-iOSUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "LionHeart-iOSUITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; B532E8522A5525C800F0DB19 /* LionHeart_iOSUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LionHeart_iOSUITests.swift; sourceTree = ""; }; B532E8542A5525C800F0DB19 /* LionHeart_iOSUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LionHeart_iOSUITestsLaunchTests.swift; sourceTree = ""; }; @@ -556,6 +556,7 @@ C03FCD412B0DD11C00C4EA0D /* UITabbarItem+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITabbarItem+.swift"; sourceTree = ""; }; C04BE3AC2ADD4F5D001967B5 /* TodayCoordinatorImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayCoordinatorImpl.swift; sourceTree = ""; }; C04BE3AE2ADD4F7F001967B5 /* TodayAdaptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayAdaptor.swift; sourceTree = ""; }; + C060EAF42B195C6600AB2855 /* LionHeart-iOS.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = "LionHeart-iOS.xctestplan"; sourceTree = ""; }; C06318072B10623000DE1995 /* ChallengeViewDiffableModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeViewDiffableModel.swift; sourceTree = ""; }; C06318132B1064C400DE1995 /* ArticleDataByWeek.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleDataByWeek.swift; sourceTree = ""; }; C06318192B10658400DE1995 /* ArticleDetailSection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleDetailSection.swift; sourceTree = ""; }; @@ -685,6 +686,7 @@ C0F62FBE2A67CDB60003ADFA /* progressbar_5m.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = progressbar_5m.json; sourceTree = ""; }; C0F62FBF2A67CDB60003ADFA /* progressbar_6m.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = progressbar_6m.json; sourceTree = ""; }; C0F62FE62A691FC40003ADFA /* LHLoadingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHLoadingView.swift; sourceTree = ""; }; + C0FF46BB2B1963D300D487D7 /* ChallengeSuccess.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = ChallengeSuccess.json; sourceTree = ""; }; D34280762A66B90C00DA1499 /* UILabelPadding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UILabelPadding.swift; sourceTree = ""; }; D34280792A67F12200DA1499 /* ChallengeDataResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeDataResponse.swift; sourceTree = ""; }; D35272D02A681E13002D7FCB /* ChallengeData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChallengeData.swift; sourceTree = ""; }; @@ -744,6 +746,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + C060EAF82B195F1E00AB2855 /* FirebaseMessaging in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -890,11 +893,13 @@ B532E8252A5525C600F0DB19 = { isa = PBXGroup; children = ( + C060EAF42B195C6600AB2855 /* LionHeart-iOS.xctestplan */, B532E8302A5525C600F0DB19 /* LionHeart-iOS */, B532E8472A5525C800F0DB19 /* LionHeart-iOSTests */, B532E8512A5525C800F0DB19 /* LionHeart-iOSUITests */, B532E82F2A5525C600F0DB19 /* Products */, C07CB8172A62C4D6000198CC /* Recovered References */, + C060EAF12B195A2800AB2855 /* Frameworks */, ); sourceTree = ""; }; @@ -927,9 +932,7 @@ isa = PBXGroup; children = ( B5BE51C32B15BD6200042EF3 /* URLSessionStub */, - B5BE51BB2B15B7B100042EF3 /* Today */, B5BE51BA2B15B79C00042EF3 /* Challenge */, - B532E8482A5525C800F0DB19 /* LionHeart_iOSTests.swift */, ); path = "LionHeart-iOSTests"; sourceTree = ""; @@ -1440,32 +1443,13 @@ B5BE51BA2B15B79C00042EF3 /* Challenge */ = { isa = PBXGroup; children = ( - B5BE51C52B15BDBD00042EF3 /* JSON */, - B5BE51BC2B15B80F00042EF3 /* ViewModelStub */, + C0FF46BA2B1963BC00D487D7 /* ChallengeJSON */, + C060EAEE2B1956C200AB2855 /* ViewControllerTest */, B5BE51BF2B15B8C300042EF3 /* ServiceTests */, - B5BE51C22B15B8F600042EF3 /* ViewControllerTests */, ); path = Challenge; sourceTree = ""; }; - B5BE51BB2B15B7B100042EF3 /* Today */ = { - isa = PBXGroup; - children = ( - B5BE51CD2B15CC5300042EF3 /* JSON */, - B5BE51CF2B15CC5B00042EF3 /* ServiceTests */, - B5BE51CE2B15CC5700042EF3 /* ViewModelStub */, - B5BE51D02B15CC5F00042EF3 /* ViewControllerTests */, - ); - path = Today; - sourceTree = ""; - }; - B5BE51BC2B15B80F00042EF3 /* ViewModelStub */ = { - isa = PBXGroup; - children = ( - ); - path = ViewModelStub; - sourceTree = ""; - }; B5BE51BF2B15B8C300042EF3 /* ServiceTests */ = { isa = PBXGroup; children = ( @@ -1474,13 +1458,6 @@ path = ServiceTests; sourceTree = ""; }; - B5BE51C22B15B8F600042EF3 /* ViewControllerTests */ = { - isa = PBXGroup; - children = ( - ); - path = ViewControllerTests; - sourceTree = ""; - }; B5BE51C32B15BD6200042EF3 /* URLSessionStub */ = { isa = PBXGroup; children = ( @@ -1490,41 +1467,6 @@ path = URLSessionStub; sourceTree = ""; }; - B5BE51C52B15BDBD00042EF3 /* JSON */ = { - isa = PBXGroup; - children = ( - ); - path = JSON; - sourceTree = ""; - }; - B5BE51CD2B15CC5300042EF3 /* JSON */ = { - isa = PBXGroup; - children = ( - ); - path = JSON; - sourceTree = ""; - }; - B5BE51CE2B15CC5700042EF3 /* ViewModelStub */ = { - isa = PBXGroup; - children = ( - ); - path = ViewModelStub; - sourceTree = ""; - }; - B5BE51CF2B15CC5B00042EF3 /* ServiceTests */ = { - isa = PBXGroup; - children = ( - ); - path = ServiceTests; - sourceTree = ""; - }; - B5BE51D02B15CC5F00042EF3 /* ViewControllerTests */ = { - isa = PBXGroup; - children = ( - ); - path = ViewControllerTests; - sourceTree = ""; - }; B5C6A2C32A5EF4AC0021BE5E /* DTO */ = { isa = PBXGroup; children = ( @@ -1704,6 +1646,20 @@ path = CoordinatorImpl; sourceTree = ""; }; + C060EAEE2B1956C200AB2855 /* ViewControllerTest */ = { + isa = PBXGroup; + children = ( + ); + path = ViewControllerTest; + sourceTree = ""; + }; + C060EAF12B195A2800AB2855 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; C06318052B1061D600DE1995 /* ViewModel */ = { isa = PBXGroup; children = ( @@ -2061,6 +2017,14 @@ path = OnboardingComponent; sourceTree = ""; }; + C0FF46BA2B1963BC00D487D7 /* ChallengeJSON */ = { + isa = PBXGroup; + children = ( + C0FF46BB2B1963D300D487D7 /* ChallengeSuccess.json */, + ); + path = ChallengeJSON; + sourceTree = ""; + }; D30CBA182A60383800C8636B /* Model */ = { isa = PBXGroup; children = ( @@ -2164,6 +2128,9 @@ B532E8462A5525C800F0DB19 /* PBXTargetDependency */, ); name = "LionHeart-iOSTests"; + packageProductDependencies = ( + C060EAF72B195F1E00AB2855 /* FirebaseMessaging */, + ); productName = "LionHeart-iOSTests"; productReference = B532E8442A5525C800F0DB19 /* LionHeart-iOSTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; @@ -2270,6 +2237,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + C0FF46BC2B1963D300D487D7 /* ChallengeSuccess.json in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2588,7 +2556,6 @@ buildActionMask = 2147483647; files = ( B5BE51C92B15CB9600042EF3 /* JSONLoader.swift in Sources */, - C034EDE02ADE3A4A00AD6FF3 /* LionHeart_iOSTests.swift in Sources */, B5BE51C12B15B8F100042EF3 /* ServiceTests.swift in Sources */, B5BE51C72B15C75F00042EF3 /* URLSessionStub.swift in Sources */, ); @@ -3080,6 +3047,11 @@ package = B59893142A5D40FC00CE1FEB /* XCRemoteSwiftPackageReference "Kingfisher" */; productName = Kingfisher; }; + C060EAF72B195F1E00AB2855 /* FirebaseMessaging */ = { + isa = XCSwiftPackageProductDependency; + package = B598926D2A56C21800CE1FEB /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */; + productName = FirebaseMessaging; + }; /* End XCSwiftPackageProductDependency section */ }; rootObject = B532E8262A5525C600F0DB19 /* Project object */; diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/xcshareddata/xcschemes/LionHeart-iOS.xcscheme b/LionHeart-iOS/LionHeart-iOS.xcodeproj/xcshareddata/xcschemes/LionHeart-iOS.xcscheme index dbf061e0..137bdf7d 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/xcshareddata/xcschemes/LionHeart-iOS.xcscheme +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/xcshareddata/xcschemes/LionHeart-iOS.xcscheme @@ -26,8 +26,13 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - shouldUseLaunchSchemeArgsEnv = "YES" - shouldAutocreateTestPlan = "YES"> + shouldUseLaunchSchemeArgsEnv = "YES"> + + + + Date: Fri, 1 Dec 2023 12:00:22 +0900 Subject: [PATCH 02/16] =?UTF-8?q?[WIP]=20=EC=B1=8C=EB=A6=B0=EC=A7=80=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20unit=20test=EC=9E=91=EC=84=B1(#198)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 4 ++ .../Network/Base/NetworkError.swift | 2 +- .../ChallengeJSON/ChallengeFailure.json | 4 ++ .../Challenge/ServiceTests/ServiceTests.swift | 37 +++++++++++++++---- 4 files changed, 38 insertions(+), 9 deletions(-) create mode 100644 LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeJSON/ChallengeFailure.json diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index 9039a1f5..8827253d 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -325,6 +325,7 @@ C0F62FCA2A67CDCE0003ADFA /* BookmarkDetailCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A8980C12A5FD6AF00746C58 /* BookmarkDetailCollectionViewCell.swift */; }; C0F62FE72A691FC40003ADFA /* LHLoadingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0F62FE62A691FC40003ADFA /* LHLoadingView.swift */; }; C0FF46BC2B1963D300D487D7 /* ChallengeSuccess.json in Resources */ = {isa = PBXBuildFile; fileRef = C0FF46BB2B1963D300D487D7 /* ChallengeSuccess.json */; }; + C0FF46BE2B19786500D487D7 /* ChallengeFailure.json in Resources */ = {isa = PBXBuildFile; fileRef = C0FF46BD2B1974CC00D487D7 /* ChallengeFailure.json */; }; D34280772A66B90C00DA1499 /* UILabelPadding.swift in Sources */ = {isa = PBXBuildFile; fileRef = D34280762A66B90C00DA1499 /* UILabelPadding.swift */; }; D342807A2A67F12200DA1499 /* ChallengeDataResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = D34280792A67F12200DA1499 /* ChallengeDataResponse.swift */; }; D35272D12A681E13002D7FCB /* ChallengeData.swift in Sources */ = {isa = PBXBuildFile; fileRef = D35272D02A681E13002D7FCB /* ChallengeData.swift */; }; @@ -687,6 +688,7 @@ C0F62FBF2A67CDB60003ADFA /* progressbar_6m.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = progressbar_6m.json; sourceTree = ""; }; C0F62FE62A691FC40003ADFA /* LHLoadingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHLoadingView.swift; sourceTree = ""; }; C0FF46BB2B1963D300D487D7 /* ChallengeSuccess.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = ChallengeSuccess.json; sourceTree = ""; }; + C0FF46BD2B1974CC00D487D7 /* ChallengeFailure.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = ChallengeFailure.json; sourceTree = ""; }; D34280762A66B90C00DA1499 /* UILabelPadding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UILabelPadding.swift; sourceTree = ""; }; D34280792A67F12200DA1499 /* ChallengeDataResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeDataResponse.swift; sourceTree = ""; }; D35272D02A681E13002D7FCB /* ChallengeData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChallengeData.swift; sourceTree = ""; }; @@ -2021,6 +2023,7 @@ isa = PBXGroup; children = ( C0FF46BB2B1963D300D487D7 /* ChallengeSuccess.json */, + C0FF46BD2B1974CC00D487D7 /* ChallengeFailure.json */, ); path = ChallengeJSON; sourceTree = ""; @@ -2237,6 +2240,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + C0FF46BE2B19786500D487D7 /* ChallengeFailure.json in Resources */, C0FF46BC2B1963D300D487D7 /* ChallengeSuccess.json in Resources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/LionHeart-iOS/LionHeart-iOS/Network/Base/NetworkError.swift b/LionHeart-iOS/LionHeart-iOS/Network/Base/NetworkError.swift index 0b2a5216..0163118e 100644 --- a/LionHeart-iOS/LionHeart-iOS/Network/Base/NetworkError.swift +++ b/LionHeart-iOS/LionHeart-iOS/Network/Base/NetworkError.swift @@ -8,7 +8,7 @@ import Foundation @frozen -enum NetworkError: Error, CustomStringConvertible { +enum NetworkError: Error, CustomStringConvertible, Equatable { case urlEncodingError case jsonDecodingError case badCasting diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeJSON/ChallengeFailure.json b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeJSON/ChallengeFailure.json new file mode 100644 index 00000000..0ac7fbbb --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeJSON/ChallengeFailure.json @@ -0,0 +1,4 @@ +{ + "code": "I001", + "message": "정보조회에성공했습니다" +} diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ServiceTests/ServiceTests.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ServiceTests/ServiceTests.swift index 680b9c87..7af01f2c 100644 --- a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ServiceTests/ServiceTests.swift +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ServiceTests/ServiceTests.swift @@ -14,12 +14,10 @@ final class ServiceTests: XCTestCase { var apiService: Requestable! var urlSession: URLSessionStub! var jsonLoader: JSONLoader! - var data: Data! var url: URL! override func setUpWithError() throws { self.jsonLoader = JSONLoader() - self.url = URL(string: "https://api/v1/challenge/progress") } override func tearDownWithError() throws { @@ -27,17 +25,17 @@ final class ServiceTests: XCTestCase { self.url = nil } - func test_챌린지API_호출이_잘되는지() async throws { + func test_챌린지API_호출을_성공했을때() async throws { //given - let url = jsonLoader.load(fileName: "ChallengeSuccessJson") - self.data = try Data(contentsOf: url) - self.urlSession = URLSessionStub(data: self.data) + self.url = jsonLoader.load(fileName: "ChallengeSuccess") + let data = try Data(contentsOf: self.url) + let urlRequest = URLRequest(url: self.url) + self.urlSession = URLSessionStub(data: data) self.apiService = APIService(session: urlSession) //when - let urlRequest = URLRequest(url: self.url) guard let result: ChallengeDataResponse = try await self.apiService.request(urlRequest) else { - return XCTFail() + return XCTFail("옵셔널언래핑에 실패했습니다") } //then @@ -46,4 +44,27 @@ final class ServiceTests: XCTestCase { XCTAssertEqual(result.day, expectation.day) XCTAssertEqual(result.attendances.count, expectation.attendances.count) } + + func test_챌린지API_호출했을때_서버에러가발생한경우() async throws { + //given + self.url = jsonLoader.load(fileName: "ChallengeFailure") + let data = try Data(contentsOf: self.url) + let urlRequest = URLRequest(url: self.url) + self.urlSession = URLSessionStub(data: data) + self.apiService = APIService(session: urlSession) + + //when + var willOccureError: NetworkError? + do { + let _: ChallengeDataResponse? = try await self.apiService.request(urlRequest) + XCTFail("성공할수없는 case입니다") + } catch { + let error = error as? NetworkError + willOccureError = error + } + + //then + let expectation = NetworkError.serverError + XCTAssertEqual(willOccureError, expectation) + } } From 7f55cc44537462dde9ceb25072d949fb5abf550f Mon Sep 17 00:00:00 2001 From: kimscastle Date: Fri, 1 Dec 2023 13:22:21 +0900 Subject: [PATCH 03/16] =?UTF-8?q?[ADD]=20Challenge=20API=ED=98=B8=EC=B6=9C?= =?UTF-8?q?=20Unit=20test=EC=9E=91=EC=84=B1(#198)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 20 +++++--- .../ChallengeFailure_Client.json | 5 ++ ...lure.json => ChallengeFailure_Server.json} | 0 ...ests.swift => ChallengeServiceTests.swift} | 50 ++++++++++++++----- 4 files changed, 54 insertions(+), 21 deletions(-) create mode 100644 LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeJSON/ChallengeFailure_Client.json rename LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeJSON/{ChallengeFailure.json => ChallengeFailure_Server.json} (100%) rename LionHeart-iOS/LionHeart-iOSTests/Challenge/ServiceTests/{ServiceTests.swift => ChallengeServiceTests.swift} (61%) diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index 8827253d..3a6e7c4a 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -120,7 +120,7 @@ B59BFD3F2ADBBF2B005D2D81 /* CurriculumFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59BFD3E2ADBBF2B005D2D81 /* CurriculumFactory.swift */; }; B59BFD412ADBBFB2005D2D81 /* MyPageFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59BFD402ADBBFB2005D2D81 /* MyPageFactory.swift */; }; B59BFD432ADBBFF5005D2D81 /* ArticleFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59BFD422ADBBFF5005D2D81 /* ArticleFactory.swift */; }; - B5BE51C12B15B8F100042EF3 /* ServiceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BE51C02B15B8F100042EF3 /* ServiceTests.swift */; }; + B5BE51C12B15B8F100042EF3 /* ChallengeServiceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BE51C02B15B8F100042EF3 /* ChallengeServiceTests.swift */; }; B5BE51C72B15C75F00042EF3 /* URLSessionStub.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BE51C62B15C75F00042EF3 /* URLSessionStub.swift */; }; B5BE51C92B15CB9600042EF3 /* JSONLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BE51C82B15CB9600042EF3 /* JSONLoader.swift */; }; B5C6A2B22A5DB0B10021BE5E /* ArticleDetailTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5C6A2B12A5DB0B10021BE5E /* ArticleDetailTableView.swift */; }; @@ -242,6 +242,7 @@ C09A33242A630A6400B40770 /* BookmarkViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF036C2A5A9C9A0037F740 /* BookmarkViewController.swift */; }; C09A564D2B030C070012A7FD /* GetPregnancyViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09A564C2B030C070012A7FD /* GetPregnancyViewModel.swift */; }; C09A564F2B030CB20012A7FD /* GetPregnancyViewModelImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09A564E2B030CB20012A7FD /* GetPregnancyViewModelImpl.swift */; }; + C0AC2ACF2B199474003BDFC0 /* ChallengeFailure_Client.json in Resources */ = {isa = PBXBuildFile; fileRef = C0AC2ACE2B199474003BDFC0 /* ChallengeFailure_Client.json */; }; C0B15E132AC010CD0058D56B /* LHKingfisherService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E122AC010CD0058D56B /* LHKingfisherService.swift */; }; C0B15E152AC011840058D56B /* LHLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E142AC011840058D56B /* LHLabel.swift */; }; C0B15E172AC015360058D56B /* LHImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E162AC015360058D56B /* LHImageView.swift */; }; @@ -325,7 +326,7 @@ C0F62FCA2A67CDCE0003ADFA /* BookmarkDetailCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A8980C12A5FD6AF00746C58 /* BookmarkDetailCollectionViewCell.swift */; }; C0F62FE72A691FC40003ADFA /* LHLoadingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0F62FE62A691FC40003ADFA /* LHLoadingView.swift */; }; C0FF46BC2B1963D300D487D7 /* ChallengeSuccess.json in Resources */ = {isa = PBXBuildFile; fileRef = C0FF46BB2B1963D300D487D7 /* ChallengeSuccess.json */; }; - C0FF46BE2B19786500D487D7 /* ChallengeFailure.json in Resources */ = {isa = PBXBuildFile; fileRef = C0FF46BD2B1974CC00D487D7 /* ChallengeFailure.json */; }; + C0FF46BE2B19786500D487D7 /* ChallengeFailure_Server.json in Resources */ = {isa = PBXBuildFile; fileRef = C0FF46BD2B1974CC00D487D7 /* ChallengeFailure_Server.json */; }; D34280772A66B90C00DA1499 /* UILabelPadding.swift in Sources */ = {isa = PBXBuildFile; fileRef = D34280762A66B90C00DA1499 /* UILabelPadding.swift */; }; D342807A2A67F12200DA1499 /* ChallengeDataResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = D34280792A67F12200DA1499 /* ChallengeDataResponse.swift */; }; D35272D12A681E13002D7FCB /* ChallengeData.swift in Sources */ = {isa = PBXBuildFile; fileRef = D35272D02A681E13002D7FCB /* ChallengeData.swift */; }; @@ -480,7 +481,7 @@ B59BFD3E2ADBBF2B005D2D81 /* CurriculumFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumFactory.swift; sourceTree = ""; }; B59BFD402ADBBFB2005D2D81 /* MyPageFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageFactory.swift; sourceTree = ""; }; B59BFD422ADBBFF5005D2D81 /* ArticleFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleFactory.swift; sourceTree = ""; }; - B5BE51C02B15B8F100042EF3 /* ServiceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServiceTests.swift; sourceTree = ""; }; + B5BE51C02B15B8F100042EF3 /* ChallengeServiceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeServiceTests.swift; sourceTree = ""; }; B5BE51C62B15C75F00042EF3 /* URLSessionStub.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLSessionStub.swift; sourceTree = ""; }; B5BE51C82B15CB9600042EF3 /* JSONLoader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONLoader.swift; sourceTree = ""; }; B5C6A2B12A5DB0B10021BE5E /* ArticleDetailTableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleDetailTableView.swift; sourceTree = ""; }; @@ -601,6 +602,7 @@ C09A33212A62D46300B40770 /* LHToastView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LHToastView.swift; sourceTree = ""; }; C09A564C2B030C070012A7FD /* GetPregnancyViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GetPregnancyViewModel.swift; sourceTree = ""; }; C09A564E2B030CB20012A7FD /* GetPregnancyViewModelImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GetPregnancyViewModelImpl.swift; sourceTree = ""; }; + C0AC2ACE2B199474003BDFC0 /* ChallengeFailure_Client.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = ChallengeFailure_Client.json; sourceTree = ""; }; C0B15E122AC010CD0058D56B /* LHKingfisherService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHKingfisherService.swift; sourceTree = ""; }; C0B15E142AC011840058D56B /* LHLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHLabel.swift; sourceTree = ""; }; C0B15E162AC015360058D56B /* LHImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHImageView.swift; sourceTree = ""; }; @@ -688,7 +690,7 @@ C0F62FBF2A67CDB60003ADFA /* progressbar_6m.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = progressbar_6m.json; sourceTree = ""; }; C0F62FE62A691FC40003ADFA /* LHLoadingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHLoadingView.swift; sourceTree = ""; }; C0FF46BB2B1963D300D487D7 /* ChallengeSuccess.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = ChallengeSuccess.json; sourceTree = ""; }; - C0FF46BD2B1974CC00D487D7 /* ChallengeFailure.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = ChallengeFailure.json; sourceTree = ""; }; + C0FF46BD2B1974CC00D487D7 /* ChallengeFailure_Server.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = ChallengeFailure_Server.json; sourceTree = ""; }; D34280762A66B90C00DA1499 /* UILabelPadding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UILabelPadding.swift; sourceTree = ""; }; D34280792A67F12200DA1499 /* ChallengeDataResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeDataResponse.swift; sourceTree = ""; }; D35272D02A681E13002D7FCB /* ChallengeData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChallengeData.swift; sourceTree = ""; }; @@ -1455,7 +1457,7 @@ B5BE51BF2B15B8C300042EF3 /* ServiceTests */ = { isa = PBXGroup; children = ( - B5BE51C02B15B8F100042EF3 /* ServiceTests.swift */, + B5BE51C02B15B8F100042EF3 /* ChallengeServiceTests.swift */, ); path = ServiceTests; sourceTree = ""; @@ -2023,7 +2025,8 @@ isa = PBXGroup; children = ( C0FF46BB2B1963D300D487D7 /* ChallengeSuccess.json */, - C0FF46BD2B1974CC00D487D7 /* ChallengeFailure.json */, + C0FF46BD2B1974CC00D487D7 /* ChallengeFailure_Server.json */, + C0AC2ACE2B199474003BDFC0 /* ChallengeFailure_Client.json */, ); path = ChallengeJSON; sourceTree = ""; @@ -2240,7 +2243,8 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - C0FF46BE2B19786500D487D7 /* ChallengeFailure.json in Resources */, + C0AC2ACF2B199474003BDFC0 /* ChallengeFailure_Client.json in Resources */, + C0FF46BE2B19786500D487D7 /* ChallengeFailure_Server.json in Resources */, C0FF46BC2B1963D300D487D7 /* ChallengeSuccess.json in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -2560,7 +2564,7 @@ buildActionMask = 2147483647; files = ( B5BE51C92B15CB9600042EF3 /* JSONLoader.swift in Sources */, - B5BE51C12B15B8F100042EF3 /* ServiceTests.swift in Sources */, + B5BE51C12B15B8F100042EF3 /* ChallengeServiceTests.swift in Sources */, B5BE51C72B15C75F00042EF3 /* URLSessionStub.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeJSON/ChallengeFailure_Client.json b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeJSON/ChallengeFailure_Client.json new file mode 100644 index 00000000..0a0b1e46 --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeJSON/ChallengeFailure_Client.json @@ -0,0 +1,5 @@ +{ + "code": "N004", + "message": "클라이언트에러" +} + diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeJSON/ChallengeFailure.json b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeJSON/ChallengeFailure_Server.json similarity index 100% rename from LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeJSON/ChallengeFailure.json rename to LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeJSON/ChallengeFailure_Server.json diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ServiceTests/ServiceTests.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ServiceTests/ChallengeServiceTests.swift similarity index 61% rename from LionHeart-iOS/LionHeart-iOSTests/Challenge/ServiceTests/ServiceTests.swift rename to LionHeart-iOS/LionHeart-iOSTests/Challenge/ServiceTests/ChallengeServiceTests.swift index 7af01f2c..33d4d8a2 100644 --- a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ServiceTests/ServiceTests.swift +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ServiceTests/ChallengeServiceTests.swift @@ -1,15 +1,15 @@ // -// ServiceTests.swift +// ChallengeServiceTests.swift // LionHeart-iOSTests // // Created by 김의성 on 12/01/23. // import XCTest -@testable import FirebaseMessaging +@testable import Firebase @testable import LionHeart_iOS -final class ServiceTests: XCTestCase { +final class ChallengeServiceTests: XCTestCase { var apiService: Requestable! var urlSession: URLSessionStub! @@ -24,14 +24,12 @@ final class ServiceTests: XCTestCase { self.jsonLoader = nil self.url = nil } + + func test_챌린지API_호출을_성공했을때() async throws { //given - self.url = jsonLoader.load(fileName: "ChallengeSuccess") - let data = try Data(contentsOf: self.url) - let urlRequest = URLRequest(url: self.url) - self.urlSession = URLSessionStub(data: data) - self.apiService = APIService(session: urlSession) + let urlRequest = try self.setChallengeAPITest(fileName: "ChallengeSuccess") //when guard let result: ChallengeDataResponse = try await self.apiService.request(urlRequest) else { @@ -47,11 +45,7 @@ final class ServiceTests: XCTestCase { func test_챌린지API_호출했을때_서버에러가발생한경우() async throws { //given - self.url = jsonLoader.load(fileName: "ChallengeFailure") - let data = try Data(contentsOf: self.url) - let urlRequest = URLRequest(url: self.url) - self.urlSession = URLSessionStub(data: data) - self.apiService = APIService(session: urlSession) + let urlRequest = try self.setChallengeAPITest(fileName: "ChallengeFailure_Server") //when var willOccureError: NetworkError? @@ -67,4 +61,34 @@ final class ServiceTests: XCTestCase { let expectation = NetworkError.serverError XCTAssertEqual(willOccureError, expectation) } + + func test_챌린지API_호출했을때_존재하지않는_챌린지인경우() async throws { + //given + let urlRequest = try self.setChallengeAPITest(fileName: "ChallengeFailure_Client") + + //when + var willOccureError: NetworkError? + do { + let _: ChallengeDataResponse? = try await self.apiService.request(urlRequest) + XCTFail("성공할수없는 case입니다") + } catch { + let error = error as? NetworkError + willOccureError = error + } + + //then + let expectation = NetworkError.clientError(code: "N004", message: "클라이언트에러") + XCTAssertEqual(willOccureError, expectation) + } +} + +private extension ChallengeServiceTests { + func setChallengeAPITest(fileName: String) throws -> URLRequest { + self.url = jsonLoader.load(fileName: fileName) + let data = try Data(contentsOf: self.url) + let urlRequest = URLRequest(url: self.url) + self.urlSession = URLSessionStub(data: data) + self.apiService = APIService(session: urlSession) + return urlRequest + } } From df3de884629cf9cd49d40c94b9fbeb77f56b9dd8 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Fri, 1 Dec 2023 13:24:14 +0900 Subject: [PATCH 04/16] =?UTF-8?q?[FIX]=20Challenge=20API=20Unit=20test?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95(#198)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Challenge/ChallengeJSON/ChallengeFailure_Server.json | 2 +- .../Challenge/ServiceTests/ChallengeServiceTests.swift | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeJSON/ChallengeFailure_Server.json b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeJSON/ChallengeFailure_Server.json index 0ac7fbbb..9107992a 100644 --- a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeJSON/ChallengeFailure_Server.json +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeJSON/ChallengeFailure_Server.json @@ -1,4 +1,4 @@ { "code": "I001", - "message": "정보조회에성공했습니다" + "message": "서버에러가발생했습니다" } diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ServiceTests/ChallengeServiceTests.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ServiceTests/ChallengeServiceTests.swift index 33d4d8a2..8664fd3f 100644 --- a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ServiceTests/ChallengeServiceTests.swift +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ServiceTests/ChallengeServiceTests.swift @@ -25,8 +25,6 @@ final class ChallengeServiceTests: XCTestCase { self.url = nil } - - func test_챌린지API_호출을_성공했을때() async throws { //given let urlRequest = try self.setChallengeAPITest(fileName: "ChallengeSuccess") @@ -40,7 +38,7 @@ final class ChallengeServiceTests: XCTestCase { let expectation = ChallengeDataResponse(babyNickname: "Test닉네임", day: 10, level: "LEVEL_ONE", attendances: ["11/1","11/2","11/3"]) XCTAssertEqual(result.babyNickname, expectation.babyNickname) XCTAssertEqual(result.day, expectation.day) - XCTAssertEqual(result.attendances.count, expectation.attendances.count) + XCTAssertEqual(result.attendances, expectation.attendances) } func test_챌린지API_호출했을때_서버에러가발생한경우() async throws { From eef019a08919fe404439d24211a6fb0b7270257c Mon Sep 17 00:00:00 2001 From: kimscastle Date: Fri, 1 Dec 2023 15:09:27 +0900 Subject: [PATCH 05/16] =?UTF-8?q?[WIP]=20ChallengeViewModel=20Unit=20test?= =?UTF-8?q?=EC=9E=91=EC=84=B1=EC=A4=91(#198)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 16 ++++ .../Challenge/Model/ChallengeData.swift | 2 +- .../ViewModel/ChallengeViewModelImpl.swift | 10 ++- .../ChallengeViewModelTestSetUp.swift | 51 +++++++++++++ .../Challenge/ChallengeViewModelTests.swift | 76 +++++++++++++++++++ .../URLSessionStub/ChallengeManagerStub.swift | 18 +++++ .../ChallengeNavigationStub.swift | 27 +++++++ 7 files changed, 196 insertions(+), 4 deletions(-) create mode 100644 LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTestSetUp.swift create mode 100644 LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTests.swift create mode 100644 LionHeart-iOS/LionHeart-iOSTests/URLSessionStub/ChallengeManagerStub.swift create mode 100644 LionHeart-iOS/LionHeart-iOSTests/URLSessionStub/ChallengeNavigationStub.swift diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index 3a6e7c4a..f1c22987 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -255,6 +255,10 @@ C0B15E272AC104D50058D56B /* LHImageButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E262AC104D50058D56B /* LHImageButton.swift */; }; C0B15E292AC106CA0058D56B /* CurriculumListByWeekTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E282AC106CA0058D56B /* CurriculumListByWeekTableView.swift */; }; C0B15E2B2AC115F90058D56B /* LHView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E2A2AC115F90058D56B /* LHView.swift */; }; + C0B234FE2B19995F00AFC5BB /* ChallengeViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B234FD2B19995F00AFC5BB /* ChallengeViewModelTests.swift */; }; + C0B235002B199E4000AFC5BB /* ChallengeManagerStub.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B234FF2B199E4000AFC5BB /* ChallengeManagerStub.swift */; }; + C0B235022B199F4D00AFC5BB /* ChallengeNavigationStub.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B235012B199F4D00AFC5BB /* ChallengeNavigationStub.swift */; }; + C0B235042B19AA4800AFC5BB /* ChallengeViewModelTestSetUp.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B235032B19AA4800AFC5BB /* ChallengeViewModelTestSetUp.swift */; }; C0D47B602B08B640003B66E6 /* ChallengeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0D47B5F2B08B640003B66E6 /* ChallengeViewModel.swift */; }; C0D47B622B08B6A3003B66E6 /* ChallengeViewModelImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0D47B612B08B6A3003B66E6 /* ChallengeViewModelImpl.swift */; }; C0D47B642B09A7A7003B66E6 /* TodayViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0D47B632B09A7A7003B66E6 /* TodayViewModel.swift */; }; @@ -615,6 +619,10 @@ C0B15E262AC104D50058D56B /* LHImageButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHImageButton.swift; sourceTree = ""; }; C0B15E282AC106CA0058D56B /* CurriculumListByWeekTableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumListByWeekTableView.swift; sourceTree = ""; }; C0B15E2A2AC115F90058D56B /* LHView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHView.swift; sourceTree = ""; }; + C0B234FD2B19995F00AFC5BB /* ChallengeViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeViewModelTests.swift; sourceTree = ""; }; + C0B234FF2B199E4000AFC5BB /* ChallengeManagerStub.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeManagerStub.swift; sourceTree = ""; }; + C0B235012B199F4D00AFC5BB /* ChallengeNavigationStub.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeNavigationStub.swift; sourceTree = ""; }; + C0B235032B19AA4800AFC5BB /* ChallengeViewModelTestSetUp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeViewModelTestSetUp.swift; sourceTree = ""; }; C0D47B5F2B08B640003B66E6 /* ChallengeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeViewModel.swift; sourceTree = ""; }; C0D47B612B08B6A3003B66E6 /* ChallengeViewModelImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeViewModelImpl.swift; sourceTree = ""; }; C0D47B632B09A7A7003B66E6 /* TodayViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayViewModel.swift; sourceTree = ""; }; @@ -1450,6 +1458,8 @@ C0FF46BA2B1963BC00D487D7 /* ChallengeJSON */, C060EAEE2B1956C200AB2855 /* ViewControllerTest */, B5BE51BF2B15B8C300042EF3 /* ServiceTests */, + C0B234FD2B19995F00AFC5BB /* ChallengeViewModelTests.swift */, + C0B235032B19AA4800AFC5BB /* ChallengeViewModelTestSetUp.swift */, ); path = Challenge; sourceTree = ""; @@ -1467,6 +1477,8 @@ children = ( B5BE51C82B15CB9600042EF3 /* JSONLoader.swift */, B5BE51C62B15C75F00042EF3 /* URLSessionStub.swift */, + C0B234FF2B199E4000AFC5BB /* ChallengeManagerStub.swift */, + C0B235012B199F4D00AFC5BB /* ChallengeNavigationStub.swift */, ); path = URLSessionStub; sourceTree = ""; @@ -2564,8 +2576,12 @@ buildActionMask = 2147483647; files = ( B5BE51C92B15CB9600042EF3 /* JSONLoader.swift in Sources */, + C0B235042B19AA4800AFC5BB /* ChallengeViewModelTestSetUp.swift in Sources */, B5BE51C12B15B8F100042EF3 /* ChallengeServiceTests.swift in Sources */, + C0B234FE2B19995F00AFC5BB /* ChallengeViewModelTests.swift in Sources */, + C0B235022B199F4D00AFC5BB /* ChallengeNavigationStub.swift in Sources */, B5BE51C72B15C75F00042EF3 /* URLSessionStub.swift in Sources */, + C0B235002B199E4000AFC5BB /* ChallengeManagerStub.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/Model/ChallengeData.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/Model/ChallengeData.swift index c3ba77c7..a76b3929 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/Model/ChallengeData.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/Model/ChallengeData.swift @@ -7,7 +7,7 @@ import UIKit -struct ChallengeData: AppData { +struct ChallengeData: AppData, Equatable { let babyDaddyName: String let howLongDay: Int let daddyLevel: String diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewModel/ChallengeViewModelImpl.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewModel/ChallengeViewModelImpl.swift index 57fdae20..c862fe64 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewModel/ChallengeViewModelImpl.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewModel/ChallengeViewModelImpl.swift @@ -10,11 +10,15 @@ import Combine final class ChallengeViewModelImpl: ChallengeViewModel, ChallengeViewModelPresentable { - private enum FlowType { case bookmarkButtonTapped, myPageButtonTapped } + enum FlowType { case bookmarkButtonTapped, myPageButtonTapped } - private let navigationSubject = PassthroughSubject() + var navigationSubject = PassthroughSubject() { + didSet { + print("✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅") + } + } private var cancelBag = Set() - private let errorSubject = PassthroughSubject() + let errorSubject = PassthroughSubject() private var navigator: ChallengeNavigation private var manager: ChallengeManager diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTestSetUp.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTestSetUp.swift new file mode 100644 index 00000000..c1595f57 --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTestSetUp.swift @@ -0,0 +1,51 @@ +// +// ChallengeViewModelTestSetUp.swift +// LionHeart-iOSTests +// +// Created by uiskim on 2023/12/01. +// + +import XCTest +import Combine +@testable import LionHeart_iOS + +class ChallengeViewModelTestSetUp: XCTestCase { + + var navigationLeftButtonTapped: PassthroughSubject! + var navigationRightButtonTapped: PassthroughSubject! + var viewWillAppearSubject: PassthroughSubject! + + var input: ChallengeViewModelInput! + var output: ChallengeViewModelOutput! + + var manager: ChallengeManagerStub! + var navigation: ChallengeNavigationStub! + var viewModel: ChallengeViewModelImpl! + var cancelBag: Set! + + override func setUp() { + self.manager = ChallengeManagerStub() + self.navigation = ChallengeNavigationStub() + self.viewModel = ChallengeViewModelImpl(navigator: self.navigation, manager: self.manager) + + self.navigationLeftButtonTapped = PassthroughSubject() + self.navigationRightButtonTapped = PassthroughSubject() + self.viewWillAppearSubject = PassthroughSubject() + + self.input = .init(navigationLeftButtonTapped: self.navigationLeftButtonTapped, navigationRightButtonTapped: self.navigationRightButtonTapped, viewWillAppearSubject: self.viewWillAppearSubject) + + self.output = viewModel.transform(input: self.input) + self.cancelBag = Set() + } + + override func tearDown() { + self.navigationLeftButtonTapped = nil + self.navigationRightButtonTapped = nil + self.viewWillAppearSubject = nil + self.input = nil + self.output = nil + self.manager = nil + self.navigation = nil + self.viewModel = nil + } +} diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTests.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTests.swift new file mode 100644 index 00000000..3ee4d3fd --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTests.swift @@ -0,0 +1,76 @@ +// +// ChallengeViewModelTests.swift +// LionHeart-iOSTests +// +// Created by uiskim on 2023/12/01. +// + +import XCTest +import Combine +@testable import LionHeart_iOS + +final class ChallengeViewModelTests: ChallengeViewModelTestSetUp { + + func test_ChallengeVM의_viewWillAppear이후의_AppData변환이_잘이루어졌을때() { + //given + self.manager.returnValue = .init(babyNickname: "test", day: 12, level: "LEVEL_ONE", attendances: []) + + //when + let expectation = XCTestExpectation(description: "manager에서 제대로된 값이 들어왔을때") + var data: ChallengeData? + output.viewWillAppearSubject + .sink { value in + data = value + expectation.fulfill() + } + .store(in: &cancelBag) + viewWillAppearSubject.send(()) + + //then + let expectedValue = ChallengeData.init(babyDaddyName: "test", howLongDay: 12, daddyLevel: "LEVEL_ONE", daddyAttendances: []) + wait(for: [expectation], timeout: 0.2) + XCTAssertEqual(data, expectedValue) + } + + func test_ChallengeVM의_viewWillAppear이후의_제대로된데이터가_전달되지않았을때() { + //given + self.manager.returnValue = nil + + //when + let expectation = XCTestExpectation(description: "manager에서 nil이 들어왔을때") + var data: ChallengeData? + output.viewWillAppearSubject + .sink { value in + data = value + expectation.fulfill() + } + .store(in: &cancelBag) + viewWillAppearSubject.send(()) + + //then + wait(for: [expectation], timeout: 0.2) + XCTAssertEqual(data, ChallengeData.empty) + } + + func test_ChallengeVM의_leftButtonTapped가_올바른값을전달하고있는지() { + //give + + + //when + let expectation = XCTestExpectation(description: "네비게이션왼쪽버튼이 눌렸을때") +// self.viewModel.navigationSubject +// .sink { flow in +// if flow == .bookmarkButtonTapped { +// self.navigation.navigationLeftButtonTapped() +// expectation.fulfill() +// } +// +// } +// .store(in: &cancelBag) + self.navigationLeftButtonTapped.send(()) + + //then + wait(for: [expectation], timeout: 2) + XCTAssertTrue(self.navigation.leftButtonTapped) + } +} diff --git a/LionHeart-iOS/LionHeart-iOSTests/URLSessionStub/ChallengeManagerStub.swift b/LionHeart-iOS/LionHeart-iOSTests/URLSessionStub/ChallengeManagerStub.swift new file mode 100644 index 00000000..319d21e7 --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOSTests/URLSessionStub/ChallengeManagerStub.swift @@ -0,0 +1,18 @@ +// +// ChallengeManagerStub.swift +// LionHeart-iOSTests +// +// Created by uiskim on 2023/12/01. +// + +import Foundation +@testable import LionHeart_iOS + +final class ChallengeManagerStub: ChallengeManager { + var returnValue: ChallengeDataResponse? + + func inquireChallengeInfo() async throws -> LionHeart_iOS.ChallengeData { + guard let returnValue else { throw NetworkError.badCasting } + return returnValue.toAppData() + } +} diff --git a/LionHeart-iOS/LionHeart-iOSTests/URLSessionStub/ChallengeNavigationStub.swift b/LionHeart-iOS/LionHeart-iOSTests/URLSessionStub/ChallengeNavigationStub.swift new file mode 100644 index 00000000..38b0c271 --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOSTests/URLSessionStub/ChallengeNavigationStub.swift @@ -0,0 +1,27 @@ +// +// ChallengeNavigationStub.swift +// LionHeart-iOSTests +// +// Created by uiskim on 2023/12/01. +// + +import Foundation +@testable import LionHeart_iOS + +final class ChallengeNavigationStub: ChallengeNavigation { + var leftButtonTapped = false + var rightButtonTapped = false + var appExit = false + + func navigationRightButtonTapped() { + self.rightButtonTapped = true + } + + func navigationLeftButtonTapped() { + self.leftButtonTapped = true + } + + func checkTokenIsExpired() { + self.appExit = true + } +} From ee72a03ceca536b46a437f48c3cc542559ebde29 Mon Sep 17 00:00:00 2001 From: MINJAE KIM Date: Fri, 1 Dec 2023 16:48:37 +0900 Subject: [PATCH 06/16] =?UTF-8?q?[WIP]=20fake=20app=20delegate=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20(#198)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 23 ++++++++----------- .../Application/AppDelegate.swift | 2 +- .../LionHeart-iOS/Application/main.swift | 17 ++++++++++++++ .../CurriculumListWeekViewController.swift | 4 +++- .../ChallengeViewModelTestSetUp.swift | 3 +++ .../Challenge/ChallengeViewModelTests.swift | 5 ++-- .../Challenge/TestingAppDelegate.swift | 21 +++++++++++++++++ 7 files changed, 58 insertions(+), 17 deletions(-) create mode 100644 LionHeart-iOS/LionHeart-iOS/Application/main.swift create mode 100644 LionHeart-iOS/LionHeart-iOSTests/Challenge/TestingAppDelegate.swift diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index f1c22987..620805f3 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -120,6 +120,9 @@ B59BFD3F2ADBBF2B005D2D81 /* CurriculumFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59BFD3E2ADBBF2B005D2D81 /* CurriculumFactory.swift */; }; B59BFD412ADBBFB2005D2D81 /* MyPageFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59BFD402ADBBFB2005D2D81 /* MyPageFactory.swift */; }; B59BFD432ADBBFF5005D2D81 /* ArticleFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59BFD422ADBBFF5005D2D81 /* ArticleFactory.swift */; }; + B59FC6BA2B19C2DC000996CA /* TestingAppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59FC6B92B19C2DC000996CA /* TestingAppDelegate.swift */; }; + B59FC6BC2B19C330000996CA /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59FC6BB2B19C330000996CA /* main.swift */; }; + B59FC6BD2B19C569000996CA /* CurriculumArticleByWeekHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4DB30BB2A61691F00413EB9 /* CurriculumArticleByWeekHeaderView.swift */; }; B5BE51C12B15B8F100042EF3 /* ChallengeServiceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BE51C02B15B8F100042EF3 /* ChallengeServiceTests.swift */; }; B5BE51C72B15C75F00042EF3 /* URLSessionStub.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BE51C62B15C75F00042EF3 /* URLSessionStub.swift */; }; B5BE51C92B15CB9600042EF3 /* JSONLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BE51C82B15CB9600042EF3 /* JSONLoader.swift */; }; @@ -197,7 +200,6 @@ C03FCD422B0DD11C00C4EA0D /* UITabbarItem+.swift in Sources */ = {isa = PBXBuildFile; fileRef = C03FCD412B0DD11C00C4EA0D /* UITabbarItem+.swift */; }; C04BE3AD2ADD4F5D001967B5 /* TodayCoordinatorImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04BE3AC2ADD4F5D001967B5 /* TodayCoordinatorImpl.swift */; }; C04BE3AF2ADD4F7F001967B5 /* TodayAdaptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04BE3AE2ADD4F7F001967B5 /* TodayAdaptor.swift */; }; - C060EAF82B195F1E00AB2855 /* FirebaseMessaging in Frameworks */ = {isa = PBXBuildFile; productRef = C060EAF72B195F1E00AB2855 /* FirebaseMessaging */; }; C06318082B10623000DE1995 /* ChallengeViewDiffableModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C06318072B10623000DE1995 /* ChallengeViewDiffableModel.swift */; }; C06318142B1064C400DE1995 /* ArticleDataByWeek.swift in Sources */ = {isa = PBXBuildFile; fileRef = C06318132B1064C400DE1995 /* ArticleDataByWeek.swift */; }; C063181A2B10658400DE1995 /* ArticleDetailSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = C06318192B10658400DE1995 /* ArticleDetailSection.swift */; }; @@ -327,7 +329,6 @@ C0F029E62A5FB9E000E0D185 /* ContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0F029E52A5FB9DF00E0D185 /* ContainerView.swift */; }; C0F029E82A5FB9EF00E0D185 /* RoundContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0F029E72A5FB9EF00E0D185 /* RoundContainerView.swift */; }; C0F029EA2A5FD32900E0D185 /* LHRoundButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0F029E92A5FD32900E0D185 /* LHRoundButton.swift */; }; - C0F62FCA2A67CDCE0003ADFA /* BookmarkDetailCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A8980C12A5FD6AF00746C58 /* BookmarkDetailCollectionViewCell.swift */; }; C0F62FE72A691FC40003ADFA /* LHLoadingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0F62FE62A691FC40003ADFA /* LHLoadingView.swift */; }; C0FF46BC2B1963D300D487D7 /* ChallengeSuccess.json in Resources */ = {isa = PBXBuildFile; fileRef = C0FF46BB2B1963D300D487D7 /* ChallengeSuccess.json */; }; C0FF46BE2B19786500D487D7 /* ChallengeFailure_Server.json in Resources */ = {isa = PBXBuildFile; fileRef = C0FF46BD2B1974CC00D487D7 /* ChallengeFailure_Server.json */; }; @@ -351,7 +352,6 @@ F47329E12A66F5D0001605D4 /* CurriculumResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = F47329E02A66F5D0001605D4 /* CurriculumResponse.swift */; }; F4DB30B02A611C9700413EB9 /* CurriculumWeekData.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4DB30AF2A611C9700413EB9 /* CurriculumWeekData.swift */; }; F4DB30B82A612D2800413EB9 /* CurriculumArticleByWeekTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4DB30B72A612D2800413EB9 /* CurriculumArticleByWeekTableViewCell.swift */; }; - F4DB30BC2A61691F00413EB9 /* CurriculumArticleByWeekHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4DB30BB2A61691F00413EB9 /* CurriculumArticleByWeekHeaderView.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -485,6 +485,8 @@ B59BFD3E2ADBBF2B005D2D81 /* CurriculumFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumFactory.swift; sourceTree = ""; }; B59BFD402ADBBFB2005D2D81 /* MyPageFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageFactory.swift; sourceTree = ""; }; B59BFD422ADBBFF5005D2D81 /* ArticleFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleFactory.swift; sourceTree = ""; }; + B59FC6B92B19C2DC000996CA /* TestingAppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestingAppDelegate.swift; sourceTree = ""; }; + B59FC6BB2B19C330000996CA /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; B5BE51C02B15B8F100042EF3 /* ChallengeServiceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeServiceTests.swift; sourceTree = ""; }; B5BE51C62B15C75F00042EF3 /* URLSessionStub.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLSessionStub.swift; sourceTree = ""; }; B5BE51C82B15CB9600042EF3 /* JSONLoader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONLoader.swift; sourceTree = ""; }; @@ -758,7 +760,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - C060EAF82B195F1E00AB2855 /* FirebaseMessaging in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1380,6 +1381,7 @@ B532E83C2A5525C700F0DB19 /* LaunchScreen.storyboard */, B532E8312A5525C600F0DB19 /* AppDelegate.swift */, B532E8332A5525C600F0DB19 /* SceneDelegate.swift */, + B59FC6BB2B19C330000996CA /* main.swift */, ); path = Application; sourceTree = ""; @@ -1460,6 +1462,7 @@ B5BE51BF2B15B8C300042EF3 /* ServiceTests */, C0B234FD2B19995F00AFC5BB /* ChallengeViewModelTests.swift */, C0B235032B19AA4800AFC5BB /* ChallengeViewModelTestSetUp.swift */, + B59FC6B92B19C2DC000996CA /* TestingAppDelegate.swift */, ); path = Challenge; sourceTree = ""; @@ -2147,7 +2150,6 @@ ); name = "LionHeart-iOSTests"; packageProductDependencies = ( - C060EAF72B195F1E00AB2855 /* FirebaseMessaging */, ); productName = "LionHeart-iOSTests"; productReference = B532E8442A5525C800F0DB19 /* LionHeart-iOSTests.xctest */; @@ -2283,6 +2285,7 @@ C0DF03732A5A9CB50037F740 /* TodayViewController.swift in Sources */, C00780B72A5FFE0E0043EB36 /* UILabel+.swift in Sources */, C003CC602ADA50AA00AFFAAC /* OnboardingManager.swift in Sources */, + B59FC6BC2B19C330000996CA /* main.swift in Sources */, C0DF03942A5B8C610037F740 /* UIFont+.swift in Sources */, B5234FB72B0C78EB00D6EE58 /* CurriculumListWeekViewController.swift in Sources */, C0B15E192AC015FE0058D56B /* LHLottie.swift in Sources */, @@ -2347,8 +2350,6 @@ C0D47B942B0B2C46003B66E6 /* MyPageViewModelImpl.swift in Sources */, C0D47B622B08B6A3003B66E6 /* ChallengeViewModelImpl.swift in Sources */, C0DF039F2A5CABC10037F740 /* GetPregnancyViewController.swift in Sources */, - F4DB30BC2A61691F00413EB9 /* CurriculumArticleByWeekHeaderView.swift in Sources */, - F4DB30BC2A61691F00413EB9 /* CurriculumArticleByWeekHeaderView.swift in Sources */, C0DF039A2A5B908E0037F740 /* CGColor+.swift in Sources */, C0D47B662B09A845003B66E6 /* TodayViewModelImpl.swift in Sources */, C034EE1E2ADE44E200AD6FF3 /* ArticleCategoryAdaptor.swift in Sources */, @@ -2372,6 +2373,7 @@ C06E38212A65351600B00600 /* SignUpRequest.swift in Sources */, C003CC432ADA4EFF00AFFAAC /* MyPageNavigation.swift in Sources */, C003CC512ADA4FA600AFFAAC /* CompleteOnboardingNavigation.swift in Sources */, + B59FC6BD2B19C569000996CA /* CurriculumArticleByWeekHeaderView.swift in Sources */, C09A33232A62D46300B40770 /* LHToastView.swift in Sources */, C0D47B962B0B3739003B66E6 /* MyPageModel.swift in Sources */, B53F4EF82ADE2FB0001C5752 /* ChallengeCoordinatorImpl.swift in Sources */, @@ -2518,7 +2520,6 @@ C0DF037B2A5A9CF30037F740 /* OnboardingViewController.swift in Sources */, 4A3F0C312B05E8E8004BD076 /* CompleteOnboardingViewModelImpl.swift in Sources */, C09217682A605DEE00231C66 /* OnboardingFetalNicknameTextFieldResultType.swift in Sources */, - C0F62FCA2A67CDCE0003ADFA /* BookmarkDetailCollectionViewCell.swift in Sources */, C0DF03592A5A9BF80037F740 /* ArticleCategoryViewController.swift in Sources */, B5234FB32B0B451800D6EE58 /* ArticleListByCategoryDiffableModel.swift in Sources */, C00780BA2A60149D0043EB36 /* LHTodayArticleTitle.swift in Sources */, @@ -2579,6 +2580,7 @@ C0B235042B19AA4800AFC5BB /* ChallengeViewModelTestSetUp.swift in Sources */, B5BE51C12B15B8F100042EF3 /* ChallengeServiceTests.swift in Sources */, C0B234FE2B19995F00AFC5BB /* ChallengeViewModelTests.swift in Sources */, + B59FC6BA2B19C2DC000996CA /* TestingAppDelegate.swift in Sources */, C0B235022B199F4D00AFC5BB /* ChallengeNavigationStub.swift in Sources */, B5BE51C72B15C75F00042EF3 /* URLSessionStub.swift in Sources */, C0B235002B199E4000AFC5BB /* ChallengeManagerStub.swift in Sources */, @@ -3071,11 +3073,6 @@ package = B59893142A5D40FC00CE1FEB /* XCRemoteSwiftPackageReference "Kingfisher" */; productName = Kingfisher; }; - C060EAF72B195F1E00AB2855 /* FirebaseMessaging */ = { - isa = XCSwiftPackageProductDependency; - package = B598926D2A56C21800CE1FEB /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */; - productName = FirebaseMessaging; - }; /* End XCSwiftPackageProductDependency section */ }; rootObject = B532E8262A5525C600F0DB19 /* Project object */; diff --git a/LionHeart-iOS/LionHeart-iOS/Application/AppDelegate.swift b/LionHeart-iOS/LionHeart-iOS/Application/AppDelegate.swift index ea3cd03c..41fb0f1b 100644 --- a/LionHeart-iOS/LionHeart-iOS/Application/AppDelegate.swift +++ b/LionHeart-iOS/LionHeart-iOS/Application/AppDelegate.swift @@ -13,7 +13,7 @@ import FirebaseMessaging import KakaoSDKCommon -@main +//@main class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { diff --git a/LionHeart-iOS/LionHeart-iOS/Application/main.swift b/LionHeart-iOS/LionHeart-iOS/Application/main.swift new file mode 100644 index 00000000..06f11492 --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOS/Application/main.swift @@ -0,0 +1,17 @@ +// +// main.swift +// LionHeart-iOS +// +// Created by 김민재 on 12/1/23. +// + +import UIKit +import Firebase +import FirebaseMessaging + +let appDelegateClass: AnyClass = NSClassFromString("TestingAppDelegate") ?? AppDelegate.self + +UIApplicationMain(CommandLine.argc, + CommandLine.unsafeArgv, + nil, + NSStringFromClass(appDelegateClass)) diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/CurriculmumListWeek/ViewController/CurriculumListWeekViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/CurriculmumListWeek/ViewController/CurriculumListWeekViewController.swift index 197f65b8..c898607f 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/CurriculmumListWeek/ViewController/CurriculumListWeekViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/CurriculmumListWeek/ViewController/CurriculumListWeekViewController.swift @@ -22,7 +22,9 @@ final class CurriculumListWeekViewController: UIViewController, CurriculumArticl private lazy var navigationBar = LHNavigationBarView(type: .curriculumByWeek, viewController: self) private var datasoruce: UITableViewDiffableDataSource! - private lazy var headerView = CurriculumArticleByWeekHeaderView(frame: .init(x: 0, y: 0, width: view.frame.size.width, height: view.frame.size.width*(200 / 375))) + private lazy var headerView = + CurriculumArticleByWeekHeaderView(frame: .init(x: 0, y: 0, width: view.frame.size.width, height: view.frame.size.width*(200 / 375))) + private let curriculumListByWeekTableView = CurriculumListByWeekTableView() private let viewModel: any CurriculumListWeekViewModel diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTestSetUp.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTestSetUp.swift index c1595f57..763123b9 100644 --- a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTestSetUp.swift +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTestSetUp.swift @@ -7,6 +7,8 @@ import XCTest import Combine +import Firebase +import FirebaseMessaging @testable import LionHeart_iOS class ChallengeViewModelTestSetUp: XCTestCase { @@ -24,6 +26,7 @@ class ChallengeViewModelTestSetUp: XCTestCase { var cancelBag: Set! override func setUp() { + FirebaseApp.configure() self.manager = ChallengeManagerStub() self.navigation = ChallengeNavigationStub() self.viewModel = ChallengeViewModelImpl(navigator: self.navigation, manager: self.manager) diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTests.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTests.swift index 3ee4d3fd..9f29d715 100644 --- a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTests.swift +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTests.swift @@ -7,6 +7,7 @@ import XCTest import Combine + @testable import LionHeart_iOS final class ChallengeViewModelTests: ChallengeViewModelTestSetUp { @@ -68,9 +69,9 @@ final class ChallengeViewModelTests: ChallengeViewModelTestSetUp { // } // .store(in: &cancelBag) self.navigationLeftButtonTapped.send(()) - + expectation.fulfill() //then - wait(for: [expectation], timeout: 2) + wait(for: [expectation], timeout: 5) XCTAssertTrue(self.navigation.leftButtonTapped) } } diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/TestingAppDelegate.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/TestingAppDelegate.swift new file mode 100644 index 00000000..f89cfec3 --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/TestingAppDelegate.swift @@ -0,0 +1,21 @@ +// +// TestingAppDelegate.swift +// LionHeart-iOSTests +// +// Created by 김민재 on 12/1/23. +// + +import UIKit +import Firebase +import FirebaseMessaging + +@objc(TestingAppDelegate) +class TestingAppDelegate: UIResponder, UIApplicationDelegate { + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { + + print("Test app delegate") + + return true + } +} From e7c367188d3e0cd512dff532d3397b04ac0efaab Mon Sep 17 00:00:00 2001 From: MINJAE KIM Date: Fri, 1 Dec 2023 17:37:41 +0900 Subject: [PATCH 07/16] =?UTF-8?q?[WIP]=20ViewModel=20unit=20test=20navigat?= =?UTF-8?q?ion=20flow=ED=83=80=EC=9E=85=20=ED=99=95=EC=9D=B8=EB=A7=8C=20?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EA=B2=83=EC=9C=BC=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20(#198)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 4 --- .../Application/AppDelegate.swift | 2 +- .../LionHeart-iOS/Application/main.swift | 17 ----------- .../ViewModel/ChallengeViewModelImpl.swift | 8 +++-- .../ChallengeViewModelTestSetUp.swift | 1 - .../Challenge/ChallengeViewModelTests.swift | 29 ++++++++++--------- .../ChallengeNavigationStub.swift | 2 +- 7 files changed, 24 insertions(+), 39 deletions(-) delete mode 100644 LionHeart-iOS/LionHeart-iOS/Application/main.swift diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index 620805f3..a5f5d9a3 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -121,7 +121,6 @@ B59BFD412ADBBFB2005D2D81 /* MyPageFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59BFD402ADBBFB2005D2D81 /* MyPageFactory.swift */; }; B59BFD432ADBBFF5005D2D81 /* ArticleFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59BFD422ADBBFF5005D2D81 /* ArticleFactory.swift */; }; B59FC6BA2B19C2DC000996CA /* TestingAppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59FC6B92B19C2DC000996CA /* TestingAppDelegate.swift */; }; - B59FC6BC2B19C330000996CA /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59FC6BB2B19C330000996CA /* main.swift */; }; B59FC6BD2B19C569000996CA /* CurriculumArticleByWeekHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4DB30BB2A61691F00413EB9 /* CurriculumArticleByWeekHeaderView.swift */; }; B5BE51C12B15B8F100042EF3 /* ChallengeServiceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BE51C02B15B8F100042EF3 /* ChallengeServiceTests.swift */; }; B5BE51C72B15C75F00042EF3 /* URLSessionStub.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BE51C62B15C75F00042EF3 /* URLSessionStub.swift */; }; @@ -486,7 +485,6 @@ B59BFD402ADBBFB2005D2D81 /* MyPageFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageFactory.swift; sourceTree = ""; }; B59BFD422ADBBFF5005D2D81 /* ArticleFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleFactory.swift; sourceTree = ""; }; B59FC6B92B19C2DC000996CA /* TestingAppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestingAppDelegate.swift; sourceTree = ""; }; - B59FC6BB2B19C330000996CA /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; B5BE51C02B15B8F100042EF3 /* ChallengeServiceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeServiceTests.swift; sourceTree = ""; }; B5BE51C62B15C75F00042EF3 /* URLSessionStub.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLSessionStub.swift; sourceTree = ""; }; B5BE51C82B15CB9600042EF3 /* JSONLoader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONLoader.swift; sourceTree = ""; }; @@ -1381,7 +1379,6 @@ B532E83C2A5525C700F0DB19 /* LaunchScreen.storyboard */, B532E8312A5525C600F0DB19 /* AppDelegate.swift */, B532E8332A5525C600F0DB19 /* SceneDelegate.swift */, - B59FC6BB2B19C330000996CA /* main.swift */, ); path = Application; sourceTree = ""; @@ -2285,7 +2282,6 @@ C0DF03732A5A9CB50037F740 /* TodayViewController.swift in Sources */, C00780B72A5FFE0E0043EB36 /* UILabel+.swift in Sources */, C003CC602ADA50AA00AFFAAC /* OnboardingManager.swift in Sources */, - B59FC6BC2B19C330000996CA /* main.swift in Sources */, C0DF03942A5B8C610037F740 /* UIFont+.swift in Sources */, B5234FB72B0C78EB00D6EE58 /* CurriculumListWeekViewController.swift in Sources */, C0B15E192AC015FE0058D56B /* LHLottie.swift in Sources */, diff --git a/LionHeart-iOS/LionHeart-iOS/Application/AppDelegate.swift b/LionHeart-iOS/LionHeart-iOS/Application/AppDelegate.swift index 41fb0f1b..ea3cd03c 100644 --- a/LionHeart-iOS/LionHeart-iOS/Application/AppDelegate.swift +++ b/LionHeart-iOS/LionHeart-iOS/Application/AppDelegate.swift @@ -13,7 +13,7 @@ import FirebaseMessaging import KakaoSDKCommon -//@main +@main class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { diff --git a/LionHeart-iOS/LionHeart-iOS/Application/main.swift b/LionHeart-iOS/LionHeart-iOS/Application/main.swift deleted file mode 100644 index 06f11492..00000000 --- a/LionHeart-iOS/LionHeart-iOS/Application/main.swift +++ /dev/null @@ -1,17 +0,0 @@ -// -// main.swift -// LionHeart-iOS -// -// Created by 김민재 on 12/1/23. -// - -import UIKit -import Firebase -import FirebaseMessaging - -let appDelegateClass: AnyClass = NSClassFromString("TestingAppDelegate") ?? AppDelegate.self - -UIApplicationMain(CommandLine.argc, - CommandLine.unsafeArgv, - nil, - NSStringFromClass(appDelegateClass)) diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewModel/ChallengeViewModelImpl.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewModel/ChallengeViewModelImpl.swift index c862fe64..4c400865 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewModel/ChallengeViewModelImpl.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewModel/ChallengeViewModelImpl.swift @@ -48,11 +48,15 @@ final class ChallengeViewModelImpl: ChallengeViewModel, ChallengeViewModelPresen .store(in: &cancelBag) input.navigationLeftButtonTapped - .sink { [weak self] in self?.navigationSubject.send(.bookmarkButtonTapped) } + .sink { [weak self] in + self?.navigationSubject.send(.bookmarkButtonTapped) + } .store(in: &cancelBag) input.navigationRightButtonTapped - .sink { [weak self] in self?.navigationSubject.send(.myPageButtonTapped) } + .sink { + [weak self] in self?.navigationSubject.send(.myPageButtonTapped) + } .store(in: &cancelBag) let viewWillAppearSubject = input.viewWillAppearSubject diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTestSetUp.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTestSetUp.swift index 763123b9..9c6a5628 100644 --- a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTestSetUp.swift +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTestSetUp.swift @@ -26,7 +26,6 @@ class ChallengeViewModelTestSetUp: XCTestCase { var cancelBag: Set! override func setUp() { - FirebaseApp.configure() self.manager = ChallengeManagerStub() self.navigation = ChallengeNavigationStub() self.viewModel = ChallengeViewModelImpl(navigator: self.navigation, manager: self.manager) diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTests.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTests.swift index 9f29d715..2f0fa0a2 100644 --- a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTests.swift +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTests.swift @@ -59,19 +59,22 @@ final class ChallengeViewModelTests: ChallengeViewModelTestSetUp { //when let expectation = XCTestExpectation(description: "네비게이션왼쪽버튼이 눌렸을때") -// self.viewModel.navigationSubject -// .sink { flow in -// if flow == .bookmarkButtonTapped { -// self.navigation.navigationLeftButtonTapped() -// expectation.fulfill() -// } -// -// } -// .store(in: &cancelBag) - self.navigationLeftButtonTapped.send(()) - expectation.fulfill() + + var flowType: ChallengeViewModelImpl.FlowType! + self.viewModel.navigationSubject + .sink { flow in + if flow == .bookmarkButtonTapped { + flowType = flow + expectation.fulfill() + } + } + .store(in: &cancelBag) + + + self.navigationLeftButtonTapped.send(()) // 1. + //then - wait(for: [expectation], timeout: 5) - XCTAssertTrue(self.navigation.leftButtonTapped) + wait(for: [expectation], timeout: 0.5) + XCTAssertEqual(flowType, .bookmarkButtonTapped) } } diff --git a/LionHeart-iOS/LionHeart-iOSTests/URLSessionStub/ChallengeNavigationStub.swift b/LionHeart-iOS/LionHeart-iOSTests/URLSessionStub/ChallengeNavigationStub.swift index 38b0c271..35990797 100644 --- a/LionHeart-iOS/LionHeart-iOSTests/URLSessionStub/ChallengeNavigationStub.swift +++ b/LionHeart-iOS/LionHeart-iOSTests/URLSessionStub/ChallengeNavigationStub.swift @@ -18,7 +18,7 @@ final class ChallengeNavigationStub: ChallengeNavigation { } func navigationLeftButtonTapped() { - self.leftButtonTapped = true + self.leftButtonTapped.toggle() } func checkTokenIsExpired() { From 4d73afe6ccadb7d13c3e78d5a021e8091c114f7a Mon Sep 17 00:00:00 2001 From: kimscastle Date: Fri, 1 Dec 2023 20:07:28 +0900 Subject: [PATCH 08/16] =?UTF-8?q?[TEST]=20ChallengeViewModel=20Unit=20test?= =?UTF-8?q?=201=EC=B0=A8=20Coverage=2092.9%(#198)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 20 ++++----- LionHeart-iOS/LionHeart-iOS.xctestplan | 1 - .../ViewModel/ChallengeViewModelImpl.swift | 6 +-- .../ChallengeViewModelTestSetUp.swift | 3 +- .../Challenge/ChallengeViewModelTests.swift | 43 ++++++++++++++----- .../Challenge/TestingAppDelegate.swift | 21 --------- .../ChallengeNavigationStub.swift | 9 ++-- 7 files changed, 45 insertions(+), 58 deletions(-) delete mode 100644 LionHeart-iOS/LionHeart-iOSTests/Challenge/TestingAppDelegate.swift diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index a5f5d9a3..5a92d734 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -120,7 +120,6 @@ B59BFD3F2ADBBF2B005D2D81 /* CurriculumFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59BFD3E2ADBBF2B005D2D81 /* CurriculumFactory.swift */; }; B59BFD412ADBBFB2005D2D81 /* MyPageFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59BFD402ADBBFB2005D2D81 /* MyPageFactory.swift */; }; B59BFD432ADBBFF5005D2D81 /* ArticleFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59BFD422ADBBFF5005D2D81 /* ArticleFactory.swift */; }; - B59FC6BA2B19C2DC000996CA /* TestingAppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59FC6B92B19C2DC000996CA /* TestingAppDelegate.swift */; }; B59FC6BD2B19C569000996CA /* CurriculumArticleByWeekHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4DB30BB2A61691F00413EB9 /* CurriculumArticleByWeekHeaderView.swift */; }; B5BE51C12B15B8F100042EF3 /* ChallengeServiceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BE51C02B15B8F100042EF3 /* ChallengeServiceTests.swift */; }; B5BE51C72B15C75F00042EF3 /* URLSessionStub.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BE51C62B15C75F00042EF3 /* URLSessionStub.swift */; }; @@ -243,6 +242,7 @@ C09A33242A630A6400B40770 /* BookmarkViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF036C2A5A9C9A0037F740 /* BookmarkViewController.swift */; }; C09A564D2B030C070012A7FD /* GetPregnancyViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09A564C2B030C070012A7FD /* GetPregnancyViewModel.swift */; }; C09A564F2B030CB20012A7FD /* GetPregnancyViewModelImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09A564E2B030CB20012A7FD /* GetPregnancyViewModelImpl.swift */; }; + C0A4BBE32B19F0F7000BDDC5 /* FirebaseMessaging in Frameworks */ = {isa = PBXBuildFile; productRef = C0A4BBE22B19F0F7000BDDC5 /* FirebaseMessaging */; }; C0AC2ACF2B199474003BDFC0 /* ChallengeFailure_Client.json in Resources */ = {isa = PBXBuildFile; fileRef = C0AC2ACE2B199474003BDFC0 /* ChallengeFailure_Client.json */; }; C0B15E132AC010CD0058D56B /* LHKingfisherService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E122AC010CD0058D56B /* LHKingfisherService.swift */; }; C0B15E152AC011840058D56B /* LHLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E142AC011840058D56B /* LHLabel.swift */; }; @@ -484,7 +484,6 @@ B59BFD3E2ADBBF2B005D2D81 /* CurriculumFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumFactory.swift; sourceTree = ""; }; B59BFD402ADBBFB2005D2D81 /* MyPageFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageFactory.swift; sourceTree = ""; }; B59BFD422ADBBFF5005D2D81 /* ArticleFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleFactory.swift; sourceTree = ""; }; - B59FC6B92B19C2DC000996CA /* TestingAppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestingAppDelegate.swift; sourceTree = ""; }; B5BE51C02B15B8F100042EF3 /* ChallengeServiceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeServiceTests.swift; sourceTree = ""; }; B5BE51C62B15C75F00042EF3 /* URLSessionStub.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLSessionStub.swift; sourceTree = ""; }; B5BE51C82B15CB9600042EF3 /* JSONLoader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONLoader.swift; sourceTree = ""; }; @@ -758,6 +757,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + C0A4BBE32B19F0F7000BDDC5 /* FirebaseMessaging in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1455,11 +1455,9 @@ isa = PBXGroup; children = ( C0FF46BA2B1963BC00D487D7 /* ChallengeJSON */, - C060EAEE2B1956C200AB2855 /* ViewControllerTest */, B5BE51BF2B15B8C300042EF3 /* ServiceTests */, C0B234FD2B19995F00AFC5BB /* ChallengeViewModelTests.swift */, C0B235032B19AA4800AFC5BB /* ChallengeViewModelTestSetUp.swift */, - B59FC6B92B19C2DC000996CA /* TestingAppDelegate.swift */, ); path = Challenge; sourceTree = ""; @@ -1662,13 +1660,6 @@ path = CoordinatorImpl; sourceTree = ""; }; - C060EAEE2B1956C200AB2855 /* ViewControllerTest */ = { - isa = PBXGroup; - children = ( - ); - path = ViewControllerTest; - sourceTree = ""; - }; C060EAF12B195A2800AB2855 /* Frameworks */ = { isa = PBXGroup; children = ( @@ -2147,6 +2138,7 @@ ); name = "LionHeart-iOSTests"; packageProductDependencies = ( + C0A4BBE22B19F0F7000BDDC5 /* FirebaseMessaging */, ); productName = "LionHeart-iOSTests"; productReference = B532E8442A5525C800F0DB19 /* LionHeart-iOSTests.xctest */; @@ -2576,7 +2568,6 @@ C0B235042B19AA4800AFC5BB /* ChallengeViewModelTestSetUp.swift in Sources */, B5BE51C12B15B8F100042EF3 /* ChallengeServiceTests.swift in Sources */, C0B234FE2B19995F00AFC5BB /* ChallengeViewModelTests.swift in Sources */, - B59FC6BA2B19C2DC000996CA /* TestingAppDelegate.swift in Sources */, C0B235022B199F4D00AFC5BB /* ChallengeNavigationStub.swift in Sources */, B5BE51C72B15C75F00042EF3 /* URLSessionStub.swift in Sources */, C0B235002B199E4000AFC5BB /* ChallengeManagerStub.swift in Sources */, @@ -3069,6 +3060,11 @@ package = B59893142A5D40FC00CE1FEB /* XCRemoteSwiftPackageReference "Kingfisher" */; productName = Kingfisher; }; + C0A4BBE22B19F0F7000BDDC5 /* FirebaseMessaging */ = { + isa = XCSwiftPackageProductDependency; + package = B598926D2A56C21800CE1FEB /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */; + productName = FirebaseMessaging; + }; /* End XCSwiftPackageProductDependency section */ }; rootObject = B532E8262A5525C600F0DB19 /* Project object */; diff --git a/LionHeart-iOS/LionHeart-iOS.xctestplan b/LionHeart-iOS/LionHeart-iOS.xctestplan index 20fe269d..2a487f45 100644 --- a/LionHeart-iOS/LionHeart-iOS.xctestplan +++ b/LionHeart-iOS/LionHeart-iOS.xctestplan @@ -9,7 +9,6 @@ } ], "defaultOptions" : { - "codeCoverage" : false, "targetForVariableExpansion" : { "containerPath" : "container:LionHeart-iOS.xcodeproj", "identifier" : "B532E82D2A5525C600F0DB19", diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewModel/ChallengeViewModelImpl.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewModel/ChallengeViewModelImpl.swift index 4c400865..6f5aa3c1 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewModel/ChallengeViewModelImpl.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewModel/ChallengeViewModelImpl.swift @@ -12,11 +12,7 @@ final class ChallengeViewModelImpl: ChallengeViewModel, ChallengeViewModelPresen enum FlowType { case bookmarkButtonTapped, myPageButtonTapped } - var navigationSubject = PassthroughSubject() { - didSet { - print("✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅") - } - } + var navigationSubject = PassthroughSubject() private var cancelBag = Set() let errorSubject = PassthroughSubject() diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTestSetUp.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTestSetUp.swift index 9c6a5628..454e937c 100644 --- a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTestSetUp.swift +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTestSetUp.swift @@ -7,8 +7,7 @@ import XCTest import Combine -import Firebase -import FirebaseMessaging +@testable import FirebaseMessaging @testable import LionHeart_iOS class ChallengeViewModelTestSetUp: XCTestCase { diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTests.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTests.swift index 2f0fa0a2..6432829c 100644 --- a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTests.swift +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTests.swift @@ -46,35 +46,56 @@ final class ChallengeViewModelTests: ChallengeViewModelTestSetUp { expectation.fulfill() } .store(in: &cancelBag) + + var willOccureError: NetworkError? + self.viewModel.errorSubject + .sink { willOccureError = $0 } + .store(in: &cancelBag) + viewWillAppearSubject.send(()) + //then wait(for: [expectation], timeout: 0.2) XCTAssertEqual(data, ChallengeData.empty) + XCTAssertEqual(willOccureError, NetworkError.badCasting) } func test_ChallengeVM의_leftButtonTapped가_올바른값을전달하고있는지() { - //give - - //when let expectation = XCTestExpectation(description: "네비게이션왼쪽버튼이 눌렸을때") var flowType: ChallengeViewModelImpl.FlowType! self.viewModel.navigationSubject .sink { flow in - if flow == .bookmarkButtonTapped { - flowType = flow - expectation.fulfill() - } + flowType = flow + self.navigation.navigationLeftButtonTapped() + expectation.fulfill() } .store(in: &cancelBag) - - self.navigationLeftButtonTapped.send(()) // 1. - + self.navigationLeftButtonTapped.send(()) //then - wait(for: [expectation], timeout: 0.5) + wait(for: [expectation], timeout: 0.3) XCTAssertEqual(flowType, .bookmarkButtonTapped) + XCTAssertTrue(self.navigation.leftButtonTapped) + } + + func test_ChallengeVM의_rightButtonTapped가_올바른값을전달하고있는지() { + //when + let expectation = XCTestExpectation(description: "네비게이션오른쪽버튼이 눌렸을때") + + var flowType: ChallengeViewModelImpl.FlowType! + self.viewModel.navigationSubject + .sink { flow in + flowType = flow + expectation.fulfill() + } + .store(in: &cancelBag) + + self.navigationRightButtonTapped.send(()) + //then + wait(for: [expectation], timeout: 0.3) + XCTAssertEqual(flowType, .myPageButtonTapped) } } diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/TestingAppDelegate.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/TestingAppDelegate.swift deleted file mode 100644 index f89cfec3..00000000 --- a/LionHeart-iOS/LionHeart-iOSTests/Challenge/TestingAppDelegate.swift +++ /dev/null @@ -1,21 +0,0 @@ -// -// TestingAppDelegate.swift -// LionHeart-iOSTests -// -// Created by 김민재 on 12/1/23. -// - -import UIKit -import Firebase -import FirebaseMessaging - -@objc(TestingAppDelegate) -class TestingAppDelegate: UIResponder, UIApplicationDelegate { - - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { - - print("Test app delegate") - - return true - } -} diff --git a/LionHeart-iOS/LionHeart-iOSTests/URLSessionStub/ChallengeNavigationStub.swift b/LionHeart-iOS/LionHeart-iOSTests/URLSessionStub/ChallengeNavigationStub.swift index 35990797..32269517 100644 --- a/LionHeart-iOS/LionHeart-iOSTests/URLSessionStub/ChallengeNavigationStub.swift +++ b/LionHeart-iOS/LionHeart-iOSTests/URLSessionStub/ChallengeNavigationStub.swift @@ -9,19 +9,16 @@ import Foundation @testable import LionHeart_iOS final class ChallengeNavigationStub: ChallengeNavigation { - var leftButtonTapped = false - var rightButtonTapped = false - var appExit = false func navigationRightButtonTapped() { - self.rightButtonTapped = true + print("왼쪽버튼눌림") } func navigationLeftButtonTapped() { - self.leftButtonTapped.toggle() + print("오른쪽버튼눌림") } func checkTokenIsExpired() { - self.appExit = true + print("앱강제종료") } } From e75ea553530b8442b1668a162c30c9df5ee8edd8 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Fri, 1 Dec 2023 21:05:44 +0900 Subject: [PATCH 09/16] =?UTF-8?q?[TEST]=20ChallengeViewController=20Unites?= =?UTF-8?q?t=EC=9E=91=EC=84=B1=EC=A4=91(#198)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit coverage 83.9% --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 40 +++++++++-- ...heckCollectionViewCollectionViewCell.swift | 2 +- .../ChallengeViewController.swift | 12 ++-- .../Stubs}/ChallengeManagerStub.swift | 0 .../Stubs}/ChallengeNavigationStub.swift | 0 .../Stubs/ChallengeViewModelStub.swift | 45 ++++++++++++ .../ChallengeViewControllerTests.swift | 71 +++++++++++++++++++ .../ChallengeViewModelTestSetUp.swift | 0 .../ChallengeViewModelTests.swift | 2 - 9 files changed, 159 insertions(+), 13 deletions(-) rename LionHeart-iOS/LionHeart-iOSTests/{URLSessionStub => Challenge/Stubs}/ChallengeManagerStub.swift (100%) rename LionHeart-iOS/LionHeart-iOSTests/{URLSessionStub => Challenge/Stubs}/ChallengeNavigationStub.swift (100%) create mode 100644 LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/ChallengeViewModelStub.swift create mode 100644 LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewControllerTests/ChallengeViewControllerTests.swift rename LionHeart-iOS/LionHeart-iOSTests/Challenge/{ => ViewModelTests}/ChallengeViewModelTestSetUp.swift (100%) rename LionHeart-iOS/LionHeart-iOSTests/Challenge/{ => ViewModelTests}/ChallengeViewModelTests.swift (96%) diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index 5a92d734..05106305 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -243,6 +243,8 @@ C09A564D2B030C070012A7FD /* GetPregnancyViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09A564C2B030C070012A7FD /* GetPregnancyViewModel.swift */; }; C09A564F2B030CB20012A7FD /* GetPregnancyViewModelImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09A564E2B030CB20012A7FD /* GetPregnancyViewModelImpl.swift */; }; C0A4BBE32B19F0F7000BDDC5 /* FirebaseMessaging in Frameworks */ = {isa = PBXBuildFile; productRef = C0A4BBE22B19F0F7000BDDC5 /* FirebaseMessaging */; }; + C0A4BBE82B19F6EB000BDDC5 /* ChallengeViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0A4BBE72B19F6EB000BDDC5 /* ChallengeViewControllerTests.swift */; }; + C0A4BBEA2B19F709000BDDC5 /* ChallengeViewModelStub.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0A4BBE92B19F709000BDDC5 /* ChallengeViewModelStub.swift */; }; C0AC2ACF2B199474003BDFC0 /* ChallengeFailure_Client.json in Resources */ = {isa = PBXBuildFile; fileRef = C0AC2ACE2B199474003BDFC0 /* ChallengeFailure_Client.json */; }; C0B15E132AC010CD0058D56B /* LHKingfisherService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E122AC010CD0058D56B /* LHKingfisherService.swift */; }; C0B15E152AC011840058D56B /* LHLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E142AC011840058D56B /* LHLabel.swift */; }; @@ -605,6 +607,8 @@ C09A33212A62D46300B40770 /* LHToastView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LHToastView.swift; sourceTree = ""; }; C09A564C2B030C070012A7FD /* GetPregnancyViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GetPregnancyViewModel.swift; sourceTree = ""; }; C09A564E2B030CB20012A7FD /* GetPregnancyViewModelImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GetPregnancyViewModelImpl.swift; sourceTree = ""; }; + C0A4BBE72B19F6EB000BDDC5 /* ChallengeViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeViewControllerTests.swift; sourceTree = ""; }; + C0A4BBE92B19F709000BDDC5 /* ChallengeViewModelStub.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeViewModelStub.swift; sourceTree = ""; }; C0AC2ACE2B199474003BDFC0 /* ChallengeFailure_Client.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = ChallengeFailure_Client.json; sourceTree = ""; }; C0B15E122AC010CD0058D56B /* LHKingfisherService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHKingfisherService.swift; sourceTree = ""; }; C0B15E142AC011840058D56B /* LHLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHLabel.swift; sourceTree = ""; }; @@ -1454,10 +1458,11 @@ B5BE51BA2B15B79C00042EF3 /* Challenge */ = { isa = PBXGroup; children = ( + C0A4BBE62B19F6D6000BDDC5 /* ViewControllerTests */, + C0A4BBE52B19F6CD000BDDC5 /* Stubs */, + C0A4BBE42B19F6BC000BDDC5 /* ViewModelTests */, C0FF46BA2B1963BC00D487D7 /* ChallengeJSON */, B5BE51BF2B15B8C300042EF3 /* ServiceTests */, - C0B234FD2B19995F00AFC5BB /* ChallengeViewModelTests.swift */, - C0B235032B19AA4800AFC5BB /* ChallengeViewModelTestSetUp.swift */, ); path = Challenge; sourceTree = ""; @@ -1475,8 +1480,6 @@ children = ( B5BE51C82B15CB9600042EF3 /* JSONLoader.swift */, B5BE51C62B15C75F00042EF3 /* URLSessionStub.swift */, - C0B234FF2B199E4000AFC5BB /* ChallengeManagerStub.swift */, - C0B235012B199F4D00AFC5BB /* ChallengeNavigationStub.swift */, ); path = URLSessionStub; sourceTree = ""; @@ -1967,6 +1970,33 @@ path = ViewModels; sourceTree = ""; }; + C0A4BBE42B19F6BC000BDDC5 /* ViewModelTests */ = { + isa = PBXGroup; + children = ( + C0B234FD2B19995F00AFC5BB /* ChallengeViewModelTests.swift */, + C0B235032B19AA4800AFC5BB /* ChallengeViewModelTestSetUp.swift */, + ); + path = ViewModelTests; + sourceTree = ""; + }; + C0A4BBE52B19F6CD000BDDC5 /* Stubs */ = { + isa = PBXGroup; + children = ( + C0B234FF2B199E4000AFC5BB /* ChallengeManagerStub.swift */, + C0B235012B199F4D00AFC5BB /* ChallengeNavigationStub.swift */, + C0A4BBE92B19F709000BDDC5 /* ChallengeViewModelStub.swift */, + ); + path = Stubs; + sourceTree = ""; + }; + C0A4BBE62B19F6D6000BDDC5 /* ViewControllerTests */ = { + isa = PBXGroup; + children = ( + C0A4BBE72B19F6EB000BDDC5 /* ChallengeViewControllerTests.swift */, + ); + path = ViewControllerTests; + sourceTree = ""; + }; C0DF03292A5A91450037F740 /* Protocols */ = { isa = PBXGroup; children = ( @@ -2566,9 +2596,11 @@ files = ( B5BE51C92B15CB9600042EF3 /* JSONLoader.swift in Sources */, C0B235042B19AA4800AFC5BB /* ChallengeViewModelTestSetUp.swift in Sources */, + C0A4BBE82B19F6EB000BDDC5 /* ChallengeViewControllerTests.swift in Sources */, B5BE51C12B15B8F100042EF3 /* ChallengeServiceTests.swift in Sources */, C0B234FE2B19995F00AFC5BB /* ChallengeViewModelTests.swift in Sources */, C0B235022B199F4D00AFC5BB /* ChallengeNavigationStub.swift in Sources */, + C0A4BBEA2B19F709000BDDC5 /* ChallengeViewModelStub.swift in Sources */, B5BE51C72B15C75F00042EF3 /* URLSessionStub.swift in Sources */, C0B235002B199E4000AFC5BB /* ChallengeManagerStub.swift in Sources */, ); diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/Cells/ChallengeDayCheckCollectionViewCollectionViewCell.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/Cells/ChallengeDayCheckCollectionViewCollectionViewCell.swift index 4aac862f..4b23c476 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/Cells/ChallengeDayCheckCollectionViewCollectionViewCell.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/Cells/ChallengeDayCheckCollectionViewCollectionViewCell.swift @@ -14,7 +14,7 @@ final class ChallengeDayCheckCollectionViewCollectionViewCell: UICollectionViewC enum ChallengeCellType { case read, yet } - private let countLabel = LHLabel(type: .body2M, color: .gray700, alignment: .center) + let countLabel = LHLabel(type: .body2M, color: .gray700, alignment: .center) private let lineView = LHUnderLine(lineColor: .gray900) override init(frame: CGRect) { diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift index eac7be80..3bdb12fc 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift @@ -24,12 +24,12 @@ final class ChallengeViewController: UIViewController, ChallengeViewControllerab private let leftSeperateLine = LHUnderLine(lineColor: .background) private let rightSeperateLine = LHUnderLine(lineColor: .background) private lazy var navigationBar = LHNavigationBarView(type: .challenge, viewController: self) - private let nicknameLabel = LHLabel(type: .body2R, color: .gray200) - private let challengeDayLabel = LHLabel(type: .head3, color: .white) - private let challengelevelLabel = LHLabel(type: .body4, color: .gray500) - private let levelBadge = LHImageView(in: ImageLiterals.ChallengeBadge.level05, contentMode: .scaleToFill) + let nicknameLabel = LHLabel(type: .body2R, color: .gray200) + let challengeDayLabel = LHLabel(type: .head3, color: .white) + let challengelevelLabel = LHLabel(type: .body4, color: .gray500) + let levelBadge = LHImageView(in: ImageLiterals.ChallengeBadge.level05, contentMode: .scaleToFill) private lazy var lottieImageView = LHLottie() - private let challengeDayCheckCollectionView = LHCollectionView() + let challengeDayCheckCollectionView = LHCollectionView() private var diffableDataSource: UICollectionViewDiffableDataSource! init(viewModel: some ChallengeViewModel) { @@ -80,7 +80,7 @@ final class ChallengeViewController: UIViewController, ChallengeViewControllerab } } -private extension ChallengeViewController { +extension ChallengeViewController { func configureData(_ input: ChallengeData) { setText(by: input) setImage(by: input) diff --git a/LionHeart-iOS/LionHeart-iOSTests/URLSessionStub/ChallengeManagerStub.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/ChallengeManagerStub.swift similarity index 100% rename from LionHeart-iOS/LionHeart-iOSTests/URLSessionStub/ChallengeManagerStub.swift rename to LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/ChallengeManagerStub.swift diff --git a/LionHeart-iOS/LionHeart-iOSTests/URLSessionStub/ChallengeNavigationStub.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/ChallengeNavigationStub.swift similarity index 100% rename from LionHeart-iOS/LionHeart-iOSTests/URLSessionStub/ChallengeNavigationStub.swift rename to LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/ChallengeNavigationStub.swift diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/ChallengeViewModelStub.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/ChallengeViewModelStub.swift new file mode 100644 index 00000000..84cd1e71 --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/ChallengeViewModelStub.swift @@ -0,0 +1,45 @@ +// +// ChallengeViewModelStub.swift +// LionHeart-iOSTests +// +// Created by uiskim on 2023/12/01. +// + +import Foundation +import Combine +@testable import LionHeart_iOS + +final class ChallengeViewModelStub: ChallengeViewModel { + + enum FlowType { case bookmarkButtonTapped, myPageButtonTapped } + + var navigationSubject = PassthroughSubject() + private var cancelBag = Set() + let errorSubject = PassthroughSubject() + + var inputData: ChallengeData! + + func transform(input: ChallengeViewModelInput) -> ChallengeViewModelOutput { + + input.navigationLeftButtonTapped + .sink { [weak self] in + self?.navigationSubject.send(.bookmarkButtonTapped) + } + .store(in: &cancelBag) + + input.navigationRightButtonTapped + .sink { + [weak self] in self?.navigationSubject.send(.myPageButtonTapped) + } + .store(in: &cancelBag) + + let viewWillAppearSubject = input.viewWillAppearSubject + .flatMap { _ -> AnyPublisher in + return Just(self.inputData) + .eraseToAnyPublisher() + } + .eraseToAnyPublisher() + + return ChallengeViewModelOutput(viewWillAppearSubject: viewWillAppearSubject) + } +} diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewControllerTests/ChallengeViewControllerTests.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewControllerTests/ChallengeViewControllerTests.swift new file mode 100644 index 00000000..ff18f75c --- /dev/null +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewControllerTests/ChallengeViewControllerTests.swift @@ -0,0 +1,71 @@ +// +// ChallengeViewControllerTests.swift +// LionHeart-iOSTests +// +// Created by uiskim on 2023/12/01. +// + +import XCTest +import Combine +@testable import LionHeart_iOS + +final class ChallengeViewControllerTests: XCTestCase { + var viewModel: ChallengeViewModelStub! + + override func setUpWithError() throws { + self.viewModel = ChallengeViewModelStub() + } + + override func tearDownWithError() throws { + self.viewModel = nil + } + + func testExample() throws { + //given + let inputData = ChallengeData(babyDaddyName: "튼튼이", howLongDay: 10, daddyLevel: "LEVEL_ONE", daddyAttendances: ["11/1", "11/2", "11/3"]) + let viewController = ChallengeViewController(viewModel: self.viewModel) + + //when + viewController.loadViewIfNeeded() + viewController.configureData(inputData) + + //then + XCTAssertEqual(viewController.nicknameLabel.text, "튼튼이아빠 님,") + XCTAssertEqual(viewController.challengeDayLabel.text, "10일째 도전 중") + XCTAssertEqual(viewController.challengelevelLabel.text, "사자력 Lv.1") + + } + + func test_Challenge현황판이_잘보이는지() { + //given + let inputData = ChallengeData(babyDaddyName: "튼튼이", howLongDay: 10, daddyLevel: "LEVEL_ONE", daddyAttendances: ["11/1", "11/2", "11/3"]) + let viewController = ChallengeViewController(viewModel: self.viewModel) + + //when + viewController.loadViewIfNeeded() + viewController.configureData(inputData) + + //then + let numberOfRows = viewController.challengeDayCheckCollectionView.numberOfItems(inSection: 0) + XCTAssertEqual(numberOfRows, 20) + + let cell0 = viewController.challengeDayCheckCollectionView.dataSource?.collectionView(viewController.challengeDayCheckCollectionView, cellForItemAt: IndexPath(row: 0, section: 0)) as! ChallengeDayCheckCollectionViewCollectionViewCell + XCTAssertEqual(cell0.countLabel.text, inputData.daddyAttendances[0]) + XCTAssertEqual(cell0.backgroundColor, .designSystem(.background)) + XCTAssertEqual(cell0.countLabel.textColor, .designSystem(.white)) + + let cell1 = viewController.challengeDayCheckCollectionView.dataSource?.collectionView(viewController.challengeDayCheckCollectionView, cellForItemAt: IndexPath(row: 1, section: 0)) as! ChallengeDayCheckCollectionViewCollectionViewCell + XCTAssertEqual(cell1.countLabel.text, inputData.daddyAttendances[1]) + XCTAssertEqual(cell1.backgroundColor, .designSystem(.background)) + XCTAssertEqual(cell1.countLabel.textColor, .designSystem(.white)) + + let cell2 = viewController.challengeDayCheckCollectionView.dataSource?.collectionView(viewController.challengeDayCheckCollectionView, cellForItemAt: IndexPath(row: 2, section: 0)) as! ChallengeDayCheckCollectionViewCollectionViewCell + XCTAssertEqual(cell2.countLabel.text, inputData.daddyAttendances[2]) + XCTAssertEqual(cell2.backgroundColor, .designSystem(.background)) + XCTAssertEqual(cell2.countLabel.textColor, .designSystem(.white)) + + let cell3 = viewController.challengeDayCheckCollectionView.dataSource?.collectionView(viewController.challengeDayCheckCollectionView, cellForItemAt: IndexPath(row: 3, section: 0)) as! ChallengeDayCheckCollectionViewCollectionViewCell + XCTAssertEqual(cell3.countLabel.text, "\(0+3+1)") + XCTAssertEqual(cell3.backgroundColor, .designSystem(.gray1000)) + } +} diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTestSetUp.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewModelTests/ChallengeViewModelTestSetUp.swift similarity index 100% rename from LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTestSetUp.swift rename to LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewModelTests/ChallengeViewModelTestSetUp.swift diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTests.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewModelTests/ChallengeViewModelTests.swift similarity index 96% rename from LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTests.swift rename to LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewModelTests/ChallengeViewModelTests.swift index 6432829c..9295d5dd 100644 --- a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeViewModelTests.swift +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewModelTests/ChallengeViewModelTests.swift @@ -69,7 +69,6 @@ final class ChallengeViewModelTests: ChallengeViewModelTestSetUp { self.viewModel.navigationSubject .sink { flow in flowType = flow - self.navigation.navigationLeftButtonTapped() expectation.fulfill() } .store(in: &cancelBag) @@ -78,7 +77,6 @@ final class ChallengeViewModelTests: ChallengeViewModelTestSetUp { //then wait(for: [expectation], timeout: 0.3) XCTAssertEqual(flowType, .bookmarkButtonTapped) - XCTAssertTrue(self.navigation.leftButtonTapped) } func test_ChallengeVM의_rightButtonTapped가_올바른값을전달하고있는지() { From a5d6bae44e49e34d950ca5eec47c370b35242d88 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Fri, 1 Dec 2023 22:04:21 +0900 Subject: [PATCH 10/16] =?UTF-8?q?[TEST]=20ChallengeVC=20=EB=B2=84=ED=8A=BC?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20test=EC=B6=94=EA=B0=80(#198)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit coverage 87.1% --- .../ChallengeViewController.swift | 2 +- .../Stubs/ChallengeViewModelStub.swift | 2 + .../ChallengeViewControllerTests.swift | 76 ++++++++++++++++++- 3 files changed, 76 insertions(+), 4 deletions(-) diff --git a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift index 3bdb12fc..2a6a9a7e 100644 --- a/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift +++ b/LionHeart-iOS/LionHeart-iOS/Scenes/Challenge/ViewController/ChallengeViewController.swift @@ -23,7 +23,7 @@ final class ChallengeViewController: UIViewController, ChallengeViewControllerab private let leftSeperateLine = LHUnderLine(lineColor: .background) private let rightSeperateLine = LHUnderLine(lineColor: .background) - private lazy var navigationBar = LHNavigationBarView(type: .challenge, viewController: self) + lazy var navigationBar = LHNavigationBarView(type: .challenge, viewController: self) let nicknameLabel = LHLabel(type: .body2R, color: .gray200) let challengeDayLabel = LHLabel(type: .head3, color: .white) let challengelevelLabel = LHLabel(type: .body4, color: .gray500) diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/ChallengeViewModelStub.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/ChallengeViewModelStub.swift index 84cd1e71..564fde17 100644 --- a/LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/ChallengeViewModelStub.swift +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/ChallengeViewModelStub.swift @@ -16,6 +16,7 @@ final class ChallengeViewModelStub: ChallengeViewModel { var navigationSubject = PassthroughSubject() private var cancelBag = Set() let errorSubject = PassthroughSubject() + var willPublishedData: ChallengeData? var inputData: ChallengeData! @@ -35,6 +36,7 @@ final class ChallengeViewModelStub: ChallengeViewModel { let viewWillAppearSubject = input.viewWillAppearSubject .flatMap { _ -> AnyPublisher in + self.willPublishedData = self.inputData return Just(self.inputData) .eraseToAnyPublisher() } diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewControllerTests/ChallengeViewControllerTests.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewControllerTests/ChallengeViewControllerTests.swift index ff18f75c..320948bc 100644 --- a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewControllerTests/ChallengeViewControllerTests.swift +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewControllerTests/ChallengeViewControllerTests.swift @@ -11,16 +11,31 @@ import Combine final class ChallengeViewControllerTests: XCTestCase { var viewModel: ChallengeViewModelStub! - + var cancelBag: Set! override func setUpWithError() throws { self.viewModel = ChallengeViewModelStub() + self.cancelBag = Set() } override func tearDownWithError() throws { self.viewModel = nil + self.cancelBag = nil + } + + func test_viewWillAppear의_시점이_viewModel에_잘_전달되었는지() { + //given + let inputData = ChallengeData(babyDaddyName: "튼튼이", howLongDay: 10, daddyLevel: "LEVEL_ONE", daddyAttendances: ["11/1", "11/2", "11/3"]) + self.viewModel.inputData = inputData + let viewController = ChallengeViewController(viewModel: self.viewModel) + + //when + viewController.loadViewIfNeeded() + viewController.viewWillAppear(false) + + XCTAssertEqual(self.viewModel.willPublishedData, inputData) } - func testExample() throws { + func test_ChallengeVC의_UserData가_UI에_잘_반영되었는지() throws { //given let inputData = ChallengeData(babyDaddyName: "튼튼이", howLongDay: 10, daddyLevel: "LEVEL_ONE", daddyAttendances: ["11/1", "11/2", "11/3"]) let viewController = ChallengeViewController(viewModel: self.viewModel) @@ -36,7 +51,7 @@ final class ChallengeViewControllerTests: XCTestCase { } - func test_Challenge현황판이_잘보이는지() { + func test_ChallengeVC의_CollectionView에_데이터가_잘들어갔는지() { //given let inputData = ChallengeData(babyDaddyName: "튼튼이", howLongDay: 10, daddyLevel: "LEVEL_ONE", daddyAttendances: ["11/1", "11/2", "11/3"]) let viewController = ChallengeViewController(viewModel: self.viewModel) @@ -68,4 +83,59 @@ final class ChallengeViewControllerTests: XCTestCase { XCTAssertEqual(cell3.countLabel.text, "\(0+3+1)") XCTAssertEqual(cell3.backgroundColor, .designSystem(.gray1000)) } + + func test_Navigation의_북마크버튼이_잘_동작하는지() { + //given + let viewController = ChallengeViewController(viewModel: self.viewModel) + viewController.loadViewIfNeeded() + + //when + let expectation = XCTestExpectation(description: "네비게이션왼쪽버튼이 눌렸을때") + var navigationType: ChallengeViewModelStub.FlowType? + viewModel.navigationSubject + .sink { type in + navigationType = type + expectation.fulfill() + } + .store(in: &cancelBag) + + viewController.navigationBar.rightFirstBarItem.sendActions(for: .touchUpInside) + + //then + wait(for: [expectation], timeout: 0.3) + XCTAssertEqual(navigationType, .bookmarkButtonTapped) + } + + func test_Navigation의_마이페이지버튼이_잘_동작하는지() { + //given + let viewController = ChallengeViewController(viewModel: self.viewModel) + viewController.loadViewIfNeeded() + + //when + let expectation = XCTestExpectation(description: "네비게이션오른쪽버튼이 눌렸을때") + var navigationType: ChallengeViewModelStub.FlowType? + viewModel.navigationSubject + .sink { type in + navigationType = type + expectation.fulfill() + } + .store(in: &cancelBag) + + viewController.navigationBar.rightSecondBarItem.sendActions(for: .touchUpInside) + + //then + wait(for: [expectation], timeout: 0.3) + XCTAssertEqual(navigationType, .myPageButtonTapped) + } + + func test_ChallengeVC의_CollectionView의_CellSize가_5분의1인지() { + //given + let viewController = ChallengeViewController(viewModel: self.viewModel) + viewController.loadViewIfNeeded() + + let collectionView = viewController.challengeDayCheckCollectionView.contentSize + + let cell0 = viewContro + + } } From 475889ced384db1389b97b6c58c63ad79b93c523 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Fri, 1 Dec 2023 22:06:14 +0900 Subject: [PATCH 11/16] =?UTF-8?q?[FIX]=20=EB=A9=94=EC=84=9C=EB=93=9C?= =?UTF-8?q?=EB=AA=85=20=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20=ED=95=84=EC=9A=94?= =?UTF-8?q?=EC=97=86=EB=8A=94=20=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C(#1?= =?UTF-8?q?98)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChallengeViewControllerTests.swift | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewControllerTests/ChallengeViewControllerTests.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewControllerTests/ChallengeViewControllerTests.swift index 320948bc..de1fe822 100644 --- a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewControllerTests/ChallengeViewControllerTests.swift +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewControllerTests/ChallengeViewControllerTests.swift @@ -12,6 +12,7 @@ import Combine final class ChallengeViewControllerTests: XCTestCase { var viewModel: ChallengeViewModelStub! var cancelBag: Set! + override func setUpWithError() throws { self.viewModel = ChallengeViewModelStub() self.cancelBag = Set() @@ -51,7 +52,7 @@ final class ChallengeViewControllerTests: XCTestCase { } - func test_ChallengeVC의_CollectionView에_데이터가_잘들어갔는지() { + func test_ChallengeVC의_CollectionView에_데이터가_잘_반영되었는지() { //given let inputData = ChallengeData(babyDaddyName: "튼튼이", howLongDay: 10, daddyLevel: "LEVEL_ONE", daddyAttendances: ["11/1", "11/2", "11/3"]) let viewController = ChallengeViewController(viewModel: self.viewModel) @@ -127,15 +128,4 @@ final class ChallengeViewControllerTests: XCTestCase { wait(for: [expectation], timeout: 0.3) XCTAssertEqual(navigationType, .myPageButtonTapped) } - - func test_ChallengeVC의_CollectionView의_CellSize가_5분의1인지() { - //given - let viewController = ChallengeViewController(viewModel: self.viewModel) - viewController.loadViewIfNeeded() - - let collectionView = viewController.challengeDayCheckCollectionView.contentSize - - let cell0 = viewContro - - } } From cde9332e7eaf9995b012a83c9f050c45d1dbdb5c Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 3 Dec 2023 09:27:02 +0900 Subject: [PATCH 12/16] =?UTF-8?q?[FIX]=20=EA=B8=B0=EC=A1=B4=EC=9D=98=20gur?= =?UTF-8?q?ad=EB=AC=B8=EC=9D=84=20=ED=86=B5=ED=95=9C=20=EC=96=B8=EB=9E=98?= =?UTF-8?q?=ED=95=91=20=EB=8C=80=EC=8B=A0=20XCTUnwrap=EB=A5=BC=20=EC=9D=B4?= =?UTF-8?q?=EC=9A=A9=ED=95=9C=20=EC=96=B8=EB=9E=98=ED=95=91=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD(#198)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Challenge/ServiceTests/ChallengeServiceTests.swift | 5 ++--- .../Challenge/ViewModelTests/ChallengeViewModelTests.swift | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ServiceTests/ChallengeServiceTests.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ServiceTests/ChallengeServiceTests.swift index 8664fd3f..771fcd46 100644 --- a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ServiceTests/ChallengeServiceTests.swift +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ServiceTests/ChallengeServiceTests.swift @@ -30,9 +30,8 @@ final class ChallengeServiceTests: XCTestCase { let urlRequest = try self.setChallengeAPITest(fileName: "ChallengeSuccess") //when - guard let result: ChallengeDataResponse = try await self.apiService.request(urlRequest) else { - return XCTFail("옵셔널언래핑에 실패했습니다") - } + let returnData: ChallengeDataResponse? = try await self.apiService.request(urlRequest) + let result = try XCTUnwrap(returnData, "언래핑실패") //then let expectation = ChallengeDataResponse(babyNickname: "Test닉네임", day: 10, level: "LEVEL_ONE", attendances: ["11/1","11/2","11/3"]) diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewModelTests/ChallengeViewModelTests.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewModelTests/ChallengeViewModelTests.swift index 9295d5dd..1103cf4c 100644 --- a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewModelTests/ChallengeViewModelTests.swift +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewModelTests/ChallengeViewModelTests.swift @@ -28,7 +28,7 @@ final class ChallengeViewModelTests: ChallengeViewModelTestSetUp { viewWillAppearSubject.send(()) //then - let expectedValue = ChallengeData.init(babyDaddyName: "test", howLongDay: 12, daddyLevel: "LEVEL_ONE", daddyAttendances: []) + let expectedValue = ChallengeData(babyDaddyName: "test", howLongDay: 12, daddyLevel: "LEVEL_ONE", daddyAttendances: []) wait(for: [expectation], timeout: 0.2) XCTAssertEqual(data, expectedValue) } From d4e708e1bb7ae5e3be898acd9846b084cd11dd9a Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 3 Dec 2023 09:47:18 +0900 Subject: [PATCH 13/16] =?UTF-8?q?[FIX]=20XCTestExpectation=EC=9D=84=20give?= =?UTF-8?q?n=EC=9C=BC=EB=A1=9C=20=EC=98=AE=EA=B9=80(#198)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChallengeViewControllerTests.swift | 4 ++-- .../ViewModelTests/ChallengeViewModelTests.swift | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewControllerTests/ChallengeViewControllerTests.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewControllerTests/ChallengeViewControllerTests.swift index de1fe822..8822ec00 100644 --- a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewControllerTests/ChallengeViewControllerTests.swift +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewControllerTests/ChallengeViewControllerTests.swift @@ -87,11 +87,11 @@ final class ChallengeViewControllerTests: XCTestCase { func test_Navigation의_북마크버튼이_잘_동작하는지() { //given + let expectation = XCTestExpectation(description: "네비게이션왼쪽버튼이 눌렸을때") let viewController = ChallengeViewController(viewModel: self.viewModel) viewController.loadViewIfNeeded() //when - let expectation = XCTestExpectation(description: "네비게이션왼쪽버튼이 눌렸을때") var navigationType: ChallengeViewModelStub.FlowType? viewModel.navigationSubject .sink { type in @@ -109,11 +109,11 @@ final class ChallengeViewControllerTests: XCTestCase { func test_Navigation의_마이페이지버튼이_잘_동작하는지() { //given + let expectation = XCTestExpectation(description: "네비게이션오른쪽버튼이 눌렸을때") let viewController = ChallengeViewController(viewModel: self.viewModel) viewController.loadViewIfNeeded() //when - let expectation = XCTestExpectation(description: "네비게이션오른쪽버튼이 눌렸을때") var navigationType: ChallengeViewModelStub.FlowType? viewModel.navigationSubject .sink { type in diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewModelTests/ChallengeViewModelTests.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewModelTests/ChallengeViewModelTests.swift index 1103cf4c..4b6174cb 100644 --- a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewModelTests/ChallengeViewModelTests.swift +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewModelTests/ChallengeViewModelTests.swift @@ -14,10 +14,10 @@ final class ChallengeViewModelTests: ChallengeViewModelTestSetUp { func test_ChallengeVM의_viewWillAppear이후의_AppData변환이_잘이루어졌을때() { //given + let expectation = XCTestExpectation(description: "manager에서 제대로된 값이 들어왔을때") self.manager.returnValue = .init(babyNickname: "test", day: 12, level: "LEVEL_ONE", attendances: []) //when - let expectation = XCTestExpectation(description: "manager에서 제대로된 값이 들어왔을때") var data: ChallengeData? output.viewWillAppearSubject .sink { value in @@ -35,11 +35,13 @@ final class ChallengeViewModelTests: ChallengeViewModelTestSetUp { func test_ChallengeVM의_viewWillAppear이후의_제대로된데이터가_전달되지않았을때() { //given + let expectation = XCTestExpectation(description: "manager에서 nil이 들어왔을때") self.manager.returnValue = nil //when - let expectation = XCTestExpectation(description: "manager에서 nil이 들어왔을때") var data: ChallengeData? + var willOccureError: NetworkError? + output.viewWillAppearSubject .sink { value in data = value @@ -47,7 +49,6 @@ final class ChallengeViewModelTests: ChallengeViewModelTestSetUp { } .store(in: &cancelBag) - var willOccureError: NetworkError? self.viewModel.errorSubject .sink { willOccureError = $0 } .store(in: &cancelBag) @@ -62,9 +63,10 @@ final class ChallengeViewModelTests: ChallengeViewModelTestSetUp { } func test_ChallengeVM의_leftButtonTapped가_올바른값을전달하고있는지() { - //when + //given let expectation = XCTestExpectation(description: "네비게이션왼쪽버튼이 눌렸을때") + //when var flowType: ChallengeViewModelImpl.FlowType! self.viewModel.navigationSubject .sink { flow in @@ -80,9 +82,10 @@ final class ChallengeViewModelTests: ChallengeViewModelTestSetUp { } func test_ChallengeVM의_rightButtonTapped가_올바른값을전달하고있는지() { - //when + //given let expectation = XCTestExpectation(description: "네비게이션오른쪽버튼이 눌렸을때") + //when var flowType: ChallengeViewModelImpl.FlowType! self.viewModel.navigationSubject .sink { flow in @@ -92,6 +95,7 @@ final class ChallengeViewModelTests: ChallengeViewModelTestSetUp { .store(in: &cancelBag) self.navigationRightButtonTapped.send(()) + //then wait(for: [expectation], timeout: 0.3) XCTAssertEqual(flowType, .myPageButtonTapped) From 7ef1d14d47e904f6340302bb4d7f30a557233b6e Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 3 Dec 2023 09:49:04 +0900 Subject: [PATCH 14/16] =?UTF-8?q?[FIX]=20viewModel=EC=9D=84=20Stub?= =?UTF-8?q?=EC=97=90=EC=84=9C=20spy=EB=A1=9C=20=EB=84=A4=EC=9D=B4=EB=B0=8D?= =?UTF-8?q?=EB=B3=80=EA=B2=BD(#198)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj | 8 ++++---- ...ngeViewModelStub.swift => ChallengeViewModelSpy.swift} | 2 +- .../ChallengeViewControllerTests.swift | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) rename LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/{ChallengeViewModelStub.swift => ChallengeViewModelSpy.swift} (96%) diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index 05106305..71451eff 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -244,7 +244,7 @@ C09A564F2B030CB20012A7FD /* GetPregnancyViewModelImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09A564E2B030CB20012A7FD /* GetPregnancyViewModelImpl.swift */; }; C0A4BBE32B19F0F7000BDDC5 /* FirebaseMessaging in Frameworks */ = {isa = PBXBuildFile; productRef = C0A4BBE22B19F0F7000BDDC5 /* FirebaseMessaging */; }; C0A4BBE82B19F6EB000BDDC5 /* ChallengeViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0A4BBE72B19F6EB000BDDC5 /* ChallengeViewControllerTests.swift */; }; - C0A4BBEA2B19F709000BDDC5 /* ChallengeViewModelStub.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0A4BBE92B19F709000BDDC5 /* ChallengeViewModelStub.swift */; }; + C0A4BBEA2B19F709000BDDC5 /* ChallengeViewModelSpy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0A4BBE92B19F709000BDDC5 /* ChallengeViewModelSpy.swift */; }; C0AC2ACF2B199474003BDFC0 /* ChallengeFailure_Client.json in Resources */ = {isa = PBXBuildFile; fileRef = C0AC2ACE2B199474003BDFC0 /* ChallengeFailure_Client.json */; }; C0B15E132AC010CD0058D56B /* LHKingfisherService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E122AC010CD0058D56B /* LHKingfisherService.swift */; }; C0B15E152AC011840058D56B /* LHLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E142AC011840058D56B /* LHLabel.swift */; }; @@ -608,7 +608,7 @@ C09A564C2B030C070012A7FD /* GetPregnancyViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GetPregnancyViewModel.swift; sourceTree = ""; }; C09A564E2B030CB20012A7FD /* GetPregnancyViewModelImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GetPregnancyViewModelImpl.swift; sourceTree = ""; }; C0A4BBE72B19F6EB000BDDC5 /* ChallengeViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeViewControllerTests.swift; sourceTree = ""; }; - C0A4BBE92B19F709000BDDC5 /* ChallengeViewModelStub.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeViewModelStub.swift; sourceTree = ""; }; + C0A4BBE92B19F709000BDDC5 /* ChallengeViewModelSpy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeViewModelSpy.swift; sourceTree = ""; }; C0AC2ACE2B199474003BDFC0 /* ChallengeFailure_Client.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = ChallengeFailure_Client.json; sourceTree = ""; }; C0B15E122AC010CD0058D56B /* LHKingfisherService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHKingfisherService.swift; sourceTree = ""; }; C0B15E142AC011840058D56B /* LHLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHLabel.swift; sourceTree = ""; }; @@ -1984,7 +1984,7 @@ children = ( C0B234FF2B199E4000AFC5BB /* ChallengeManagerStub.swift */, C0B235012B199F4D00AFC5BB /* ChallengeNavigationStub.swift */, - C0A4BBE92B19F709000BDDC5 /* ChallengeViewModelStub.swift */, + C0A4BBE92B19F709000BDDC5 /* ChallengeViewModelSpy.swift */, ); path = Stubs; sourceTree = ""; @@ -2600,7 +2600,7 @@ B5BE51C12B15B8F100042EF3 /* ChallengeServiceTests.swift in Sources */, C0B234FE2B19995F00AFC5BB /* ChallengeViewModelTests.swift in Sources */, C0B235022B199F4D00AFC5BB /* ChallengeNavigationStub.swift in Sources */, - C0A4BBEA2B19F709000BDDC5 /* ChallengeViewModelStub.swift in Sources */, + C0A4BBEA2B19F709000BDDC5 /* ChallengeViewModelSpy.swift in Sources */, B5BE51C72B15C75F00042EF3 /* URLSessionStub.swift in Sources */, C0B235002B199E4000AFC5BB /* ChallengeManagerStub.swift in Sources */, ); diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/ChallengeViewModelStub.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/ChallengeViewModelSpy.swift similarity index 96% rename from LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/ChallengeViewModelStub.swift rename to LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/ChallengeViewModelSpy.swift index 564fde17..3b4a3aa5 100644 --- a/LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/ChallengeViewModelStub.swift +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/ChallengeViewModelSpy.swift @@ -9,7 +9,7 @@ import Foundation import Combine @testable import LionHeart_iOS -final class ChallengeViewModelStub: ChallengeViewModel { +final class ChallengeViewModelSpy: ChallengeViewModel { enum FlowType { case bookmarkButtonTapped, myPageButtonTapped } diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewControllerTests/ChallengeViewControllerTests.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewControllerTests/ChallengeViewControllerTests.swift index 8822ec00..0645bf2c 100644 --- a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewControllerTests/ChallengeViewControllerTests.swift +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewControllerTests/ChallengeViewControllerTests.swift @@ -10,11 +10,11 @@ import Combine @testable import LionHeart_iOS final class ChallengeViewControllerTests: XCTestCase { - var viewModel: ChallengeViewModelStub! + var viewModel: ChallengeViewModelSpy! var cancelBag: Set! override func setUpWithError() throws { - self.viewModel = ChallengeViewModelStub() + self.viewModel = ChallengeViewModelSpy() self.cancelBag = Set() } @@ -92,7 +92,7 @@ final class ChallengeViewControllerTests: XCTestCase { viewController.loadViewIfNeeded() //when - var navigationType: ChallengeViewModelStub.FlowType? + var navigationType: ChallengeViewModelSpy.FlowType? viewModel.navigationSubject .sink { type in navigationType = type @@ -114,7 +114,7 @@ final class ChallengeViewControllerTests: XCTestCase { viewController.loadViewIfNeeded() //when - var navigationType: ChallengeViewModelStub.FlowType? + var navigationType: ChallengeViewModelSpy.FlowType? viewModel.navigationSubject .sink { type in navigationType = type From 0dbcde732feda811399062091e33b16f60b18ea7 Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 3 Dec 2023 12:16:03 +0900 Subject: [PATCH 15/16] =?UTF-8?q?[FIX]=20firebase=EC=98=A4=EB=A5=98?= =?UTF-8?q?=ED=95=B4=EA=B2=B0(=EC=B0=AC=EB=AF=B8=EA=B0=80=ED=95=B4?= =?UTF-8?q?=EA=B2=B0=ED=95=B4=EC=A4=8C)(#198)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test target -> Build Settings -> Testing -> TestHost의 경로가 //두개로 되어있는걸 /로 바꿈(더블클릭하면 /하나로되어있는데 그냥 /지우면 /한개로 뜸) --- .../LionHeart-iOS.xcodeproj/project.pbxproj | 12 ++---------- .../ServiceTests/ChallengeServiceTests.swift | 1 - .../ViewModelTests/ChallengeViewModelTestSetUp.swift | 2 +- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index 71451eff..6be6457e 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -242,7 +242,6 @@ C09A33242A630A6400B40770 /* BookmarkViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DF036C2A5A9C9A0037F740 /* BookmarkViewController.swift */; }; C09A564D2B030C070012A7FD /* GetPregnancyViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09A564C2B030C070012A7FD /* GetPregnancyViewModel.swift */; }; C09A564F2B030CB20012A7FD /* GetPregnancyViewModelImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C09A564E2B030CB20012A7FD /* GetPregnancyViewModelImpl.swift */; }; - C0A4BBE32B19F0F7000BDDC5 /* FirebaseMessaging in Frameworks */ = {isa = PBXBuildFile; productRef = C0A4BBE22B19F0F7000BDDC5 /* FirebaseMessaging */; }; C0A4BBE82B19F6EB000BDDC5 /* ChallengeViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0A4BBE72B19F6EB000BDDC5 /* ChallengeViewControllerTests.swift */; }; C0A4BBEA2B19F709000BDDC5 /* ChallengeViewModelSpy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0A4BBE92B19F709000BDDC5 /* ChallengeViewModelSpy.swift */; }; C0AC2ACF2B199474003BDFC0 /* ChallengeFailure_Client.json in Resources */ = {isa = PBXBuildFile; fileRef = C0AC2ACE2B199474003BDFC0 /* ChallengeFailure_Client.json */; }; @@ -761,7 +760,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - C0A4BBE32B19F0F7000BDDC5 /* FirebaseMessaging in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2168,7 +2166,6 @@ ); name = "LionHeart-iOSTests"; packageProductDependencies = ( - C0A4BBE22B19F0F7000BDDC5 /* FirebaseMessaging */, ); productName = "LionHeart-iOSTests"; productReference = B532E8442A5525C800F0DB19 /* LionHeart-iOSTests.xctest */; @@ -2846,7 +2843,7 @@ SWIFT_EMIT_LOC_STRINGS = NO; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LionHeart-iOS.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/LionHeart-iOS"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LionHeart-iOS.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)LionHeart-iOS"; }; name = Debug; }; @@ -2872,7 +2869,7 @@ SWIFT_EMIT_LOC_STRINGS = NO; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LionHeart-iOS.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/LionHeart-iOS"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LionHeart-iOS.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)LionHeart-iOS"; }; name = Release; }; @@ -3092,11 +3089,6 @@ package = B59893142A5D40FC00CE1FEB /* XCRemoteSwiftPackageReference "Kingfisher" */; productName = Kingfisher; }; - C0A4BBE22B19F0F7000BDDC5 /* FirebaseMessaging */ = { - isa = XCSwiftPackageProductDependency; - package = B598926D2A56C21800CE1FEB /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */; - productName = FirebaseMessaging; - }; /* End XCSwiftPackageProductDependency section */ }; rootObject = B532E8262A5525C600F0DB19 /* Project object */; diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ServiceTests/ChallengeServiceTests.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ServiceTests/ChallengeServiceTests.swift index 771fcd46..664c7790 100644 --- a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ServiceTests/ChallengeServiceTests.swift +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ServiceTests/ChallengeServiceTests.swift @@ -6,7 +6,6 @@ // import XCTest -@testable import Firebase @testable import LionHeart_iOS final class ChallengeServiceTests: XCTestCase { diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewModelTests/ChallengeViewModelTestSetUp.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewModelTests/ChallengeViewModelTestSetUp.swift index 454e937c..44e9be96 100644 --- a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewModelTests/ChallengeViewModelTestSetUp.swift +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewModelTests/ChallengeViewModelTestSetUp.swift @@ -7,7 +7,7 @@ import XCTest import Combine -@testable import FirebaseMessaging + @testable import LionHeart_iOS class ChallengeViewModelTestSetUp: XCTestCase { From 070f0be1d459e1468c1a5d4d5e135aac3749cf1b Mon Sep 17 00:00:00 2001 From: kimscastle Date: Sun, 3 Dec 2023 12:26:20 +0900 Subject: [PATCH 16/16] =?UTF-8?q?[FIX]=20=EA=B8=B0=EC=A1=B4=20stub?= =?UTF-8?q?=EB=A5=BC=20=EC=97=AD=ED=95=A0=EC=97=90=EB=94=B0=EB=9D=BC=20spy?= =?UTF-8?q?=EC=99=80=20dummy=EB=A1=9C=20=EB=B3=80=EA=B2=BD(#198)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj | 8 ++++---- ...avigationStub.swift => ChallengeNavigationDummy.swift} | 2 +- .../ViewModelTests/ChallengeViewModelTestSetUp.swift | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) rename LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/{ChallengeNavigationStub.swift => ChallengeNavigationDummy.swift} (87%) diff --git a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj index 6be6457e..e31d19f8 100644 --- a/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj +++ b/LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj @@ -259,7 +259,7 @@ C0B15E2B2AC115F90058D56B /* LHView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B15E2A2AC115F90058D56B /* LHView.swift */; }; C0B234FE2B19995F00AFC5BB /* ChallengeViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B234FD2B19995F00AFC5BB /* ChallengeViewModelTests.swift */; }; C0B235002B199E4000AFC5BB /* ChallengeManagerStub.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B234FF2B199E4000AFC5BB /* ChallengeManagerStub.swift */; }; - C0B235022B199F4D00AFC5BB /* ChallengeNavigationStub.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B235012B199F4D00AFC5BB /* ChallengeNavigationStub.swift */; }; + C0B235022B199F4D00AFC5BB /* ChallengeNavigationDummy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B235012B199F4D00AFC5BB /* ChallengeNavigationDummy.swift */; }; C0B235042B19AA4800AFC5BB /* ChallengeViewModelTestSetUp.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0B235032B19AA4800AFC5BB /* ChallengeViewModelTestSetUp.swift */; }; C0D47B602B08B640003B66E6 /* ChallengeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0D47B5F2B08B640003B66E6 /* ChallengeViewModel.swift */; }; C0D47B622B08B6A3003B66E6 /* ChallengeViewModelImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0D47B612B08B6A3003B66E6 /* ChallengeViewModelImpl.swift */; }; @@ -623,7 +623,7 @@ C0B15E2A2AC115F90058D56B /* LHView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LHView.swift; sourceTree = ""; }; C0B234FD2B19995F00AFC5BB /* ChallengeViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeViewModelTests.swift; sourceTree = ""; }; C0B234FF2B199E4000AFC5BB /* ChallengeManagerStub.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeManagerStub.swift; sourceTree = ""; }; - C0B235012B199F4D00AFC5BB /* ChallengeNavigationStub.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeNavigationStub.swift; sourceTree = ""; }; + C0B235012B199F4D00AFC5BB /* ChallengeNavigationDummy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeNavigationDummy.swift; sourceTree = ""; }; C0B235032B19AA4800AFC5BB /* ChallengeViewModelTestSetUp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeViewModelTestSetUp.swift; sourceTree = ""; }; C0D47B5F2B08B640003B66E6 /* ChallengeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeViewModel.swift; sourceTree = ""; }; C0D47B612B08B6A3003B66E6 /* ChallengeViewModelImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeViewModelImpl.swift; sourceTree = ""; }; @@ -1981,7 +1981,7 @@ isa = PBXGroup; children = ( C0B234FF2B199E4000AFC5BB /* ChallengeManagerStub.swift */, - C0B235012B199F4D00AFC5BB /* ChallengeNavigationStub.swift */, + C0B235012B199F4D00AFC5BB /* ChallengeNavigationDummy.swift */, C0A4BBE92B19F709000BDDC5 /* ChallengeViewModelSpy.swift */, ); path = Stubs; @@ -2596,7 +2596,7 @@ C0A4BBE82B19F6EB000BDDC5 /* ChallengeViewControllerTests.swift in Sources */, B5BE51C12B15B8F100042EF3 /* ChallengeServiceTests.swift in Sources */, C0B234FE2B19995F00AFC5BB /* ChallengeViewModelTests.swift in Sources */, - C0B235022B199F4D00AFC5BB /* ChallengeNavigationStub.swift in Sources */, + C0B235022B199F4D00AFC5BB /* ChallengeNavigationDummy.swift in Sources */, C0A4BBEA2B19F709000BDDC5 /* ChallengeViewModelSpy.swift in Sources */, B5BE51C72B15C75F00042EF3 /* URLSessionStub.swift in Sources */, C0B235002B199E4000AFC5BB /* ChallengeManagerStub.swift in Sources */, diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/ChallengeNavigationStub.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/ChallengeNavigationDummy.swift similarity index 87% rename from LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/ChallengeNavigationStub.swift rename to LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/ChallengeNavigationDummy.swift index 32269517..e37d2250 100644 --- a/LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/ChallengeNavigationStub.swift +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/ChallengeNavigationDummy.swift @@ -8,7 +8,7 @@ import Foundation @testable import LionHeart_iOS -final class ChallengeNavigationStub: ChallengeNavigation { +final class ChallengeNavigationDummy: ChallengeNavigation { func navigationRightButtonTapped() { print("왼쪽버튼눌림") diff --git a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewModelTests/ChallengeViewModelTestSetUp.swift b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewModelTests/ChallengeViewModelTestSetUp.swift index 44e9be96..a68a9f14 100644 --- a/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewModelTests/ChallengeViewModelTestSetUp.swift +++ b/LionHeart-iOS/LionHeart-iOSTests/Challenge/ViewModelTests/ChallengeViewModelTestSetUp.swift @@ -20,13 +20,13 @@ class ChallengeViewModelTestSetUp: XCTestCase { var output: ChallengeViewModelOutput! var manager: ChallengeManagerStub! - var navigation: ChallengeNavigationStub! + var navigation: ChallengeNavigationDummy! var viewModel: ChallengeViewModelImpl! var cancelBag: Set! override func setUp() { self.manager = ChallengeManagerStub() - self.navigation = ChallengeNavigationStub() + self.navigation = ChallengeNavigationDummy() self.viewModel = ChallengeViewModelImpl(navigator: self.navigation, manager: self.manager) self.navigationLeftButtonTapped = PassthroughSubject()