From 0d849bf4564e5e1ee068f6b2f3618c896178099d Mon Sep 17 00:00:00 2001 From: dahun-lee-daji Date: Wed, 28 Apr 2021 19:09:50 +0900 Subject: [PATCH] =?UTF-8?q?Test:=20MockNetwork=ED=81=B4=EB=9E=98=EC=8A=A4?= =?UTF-8?q?=EC=99=80=20UnitTest=EC=9E=91=EC=84=B1=20(#23)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SideDishApp.xcodeproj/project.pbxproj | 145 +++++++++++++++++- .../SideDishApp/Application/AppDelegate.swift | 20 --- .../Data/Network/MockNetworkManager.swift | 46 ++++++ .../Data/Network/NetworkManager.swift | 10 +- .../SideDishApp/Domain/Entity/Dish.swift | 25 ++- SideDishApp/SideDishAppTests/Info.plist | 22 +++ .../SideDishAppTests/NetworkTests.swift | 34 ++++ .../SideDishAppTests/SideDishAppTests.swift | 32 ++++ SideDishApp/SideDishAppTests/testData.json | 6 + 9 files changed, 314 insertions(+), 26 deletions(-) create mode 100644 SideDishApp/SideDishApp/Data/Network/MockNetworkManager.swift create mode 100644 SideDishApp/SideDishAppTests/Info.plist create mode 100644 SideDishApp/SideDishAppTests/NetworkTests.swift create mode 100644 SideDishApp/SideDishAppTests/SideDishAppTests.swift create mode 100644 SideDishApp/SideDishAppTests/testData.json diff --git a/SideDishApp/SideDishApp.xcodeproj/project.pbxproj b/SideDishApp/SideDishApp.xcodeproj/project.pbxproj index bd85f5bde..d46678f99 100644 --- a/SideDishApp/SideDishApp.xcodeproj/project.pbxproj +++ b/SideDishApp/SideDishApp.xcodeproj/project.pbxproj @@ -24,12 +24,27 @@ 1ECF2EBC2635D6FD006982BE /* MenuRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ECF2EBB2635D6FD006982BE /* MenuRepository.swift */; }; 1ECF2EC02635DE65006982BE /* CoreData.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 1ECF2EBE2635DE65006982BE /* CoreData.xcdatamodeld */; }; 1ECF2EC32635E2EC006982BE /* CoreDataMenuResponseStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ECF2EC22635E2EC006982BE /* CoreDataMenuResponseStorage.swift */; }; + B04466392637B17600DAD616 /* MockNetworkManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = B04466382637B17600DAD616 /* MockNetworkManager.swift */; }; + B04466432638149900DAD616 /* SideDishAppTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B04466422638149900DAD616 /* SideDishAppTests.swift */; }; + B044664D263814B400DAD616 /* NetworkTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B044664C263814B400DAD616 /* NetworkTests.swift */; }; + B04466512638152200DAD616 /* testData.json in Resources */ = {isa = PBXBuildFile; fileRef = B04466502638152200DAD616 /* testData.json */; }; + B044665D26383DD500DAD616 /* testData.json in Resources */ = {isa = PBXBuildFile; fileRef = B04466502638152200DAD616 /* testData.json */; }; B0911E6F262EA29200D5EBEC /* DishCardCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0911E6E262EA29200D5EBEC /* DishCardCell.swift */; }; B0911EA026316B9A00D5EBEC /* String+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0911E9F26316B9A00D5EBEC /* String+Extension.swift */; }; B0911EA42631AF3400D5EBEC /* DiffableProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0911EA32631AF3400D5EBEC /* DiffableProvider.swift */; }; D8279798DA0A1BCEB97E7780 /* Pods_SideDishApp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96A87B12151B0D006007CD63 /* Pods_SideDishApp.framework */; }; /* End PBXBuildFile section */ +/* Begin PBXContainerItemProxy section */ + B04466452638149900DAD616 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 1E1DBAC6262DDDFC0050FE6C /* Project object */; + proxyType = 1; + remoteGlobalIDString = 1E1DBACD262DDDFC0050FE6C; + remoteInfo = SideDishApp; + }; +/* End PBXContainerItemProxy section */ + /* Begin PBXFileReference section */ 1E1DBACE262DDDFC0050FE6C /* SideDishApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SideDishApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 1E1DBAD1262DDDFC0050FE6C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -53,6 +68,12 @@ 4942C5A177086C5C99933038 /* Pods-SideDishApp.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SideDishApp.debug.xcconfig"; path = "Target Support Files/Pods-SideDishApp/Pods-SideDishApp.debug.xcconfig"; sourceTree = ""; }; 605A37FD869863C7E023EE85 /* Pods-SideDishApp.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SideDishApp.release.xcconfig"; path = "Target Support Files/Pods-SideDishApp/Pods-SideDishApp.release.xcconfig"; sourceTree = ""; }; 96A87B12151B0D006007CD63 /* Pods_SideDishApp.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SideDishApp.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + B04466382637B17600DAD616 /* MockNetworkManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockNetworkManager.swift; sourceTree = ""; }; + B04466402638149900DAD616 /* SideDishAppTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SideDishAppTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + B04466422638149900DAD616 /* SideDishAppTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SideDishAppTests.swift; sourceTree = ""; }; + B04466442638149900DAD616 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + B044664C263814B400DAD616 /* NetworkTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkTests.swift; sourceTree = ""; }; + B04466502638152200DAD616 /* testData.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = testData.json; sourceTree = ""; }; B0911E6E262EA29200D5EBEC /* DishCardCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DishCardCell.swift; sourceTree = ""; }; B0911E9F26316B9A00D5EBEC /* String+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Extension.swift"; sourceTree = ""; }; B0911EA32631AF3400D5EBEC /* DiffableProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiffableProvider.swift; sourceTree = ""; }; @@ -67,6 +88,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + B044663D2638149900DAD616 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -82,6 +110,7 @@ isa = PBXGroup; children = ( 1E1DBAD0262DDDFC0050FE6C /* SideDishApp */, + B04466412638149900DAD616 /* SideDishAppTests */, 1E1DBACF262DDDFC0050FE6C /* Products */, 25F4FE78497FA432687D2A6F /* Pods */, 134494D3AD3A3BAD38EFF6AF /* Frameworks */, @@ -92,6 +121,7 @@ isa = PBXGroup; children = ( 1E1DBACE262DDDFC0050FE6C /* SideDishApp.app */, + B04466402638149900DAD616 /* SideDishAppTests.xctest */, ); name = Products; sourceTree = ""; @@ -123,6 +153,7 @@ children = ( 1ECD5F61262F256000DC56C0 /* Endpoint.swift */, 1ECD5F65262F2E1E00DC56C0 /* NetworkManager.swift */, + B04466382637B17600DAD616 /* MockNetworkManager.swift */, 1ECD5F69262F3B6500DC56C0 /* DishNetworkManager.swift */, ); path = Network; @@ -245,6 +276,17 @@ path = Pods; sourceTree = ""; }; + B04466412638149900DAD616 /* SideDishAppTests */ = { + isa = PBXGroup; + children = ( + B04466502638152200DAD616 /* testData.json */, + B04466422638149900DAD616 /* SideDishAppTests.swift */, + B04466442638149900DAD616 /* Info.plist */, + B044664C263814B400DAD616 /* NetworkTests.swift */, + ); + path = SideDishAppTests; + sourceTree = ""; + }; B0911E9E26316B8700D5EBEC /* Extension */ = { isa = PBXGroup; children = ( @@ -275,18 +317,40 @@ productReference = 1E1DBACE262DDDFC0050FE6C /* SideDishApp.app */; productType = "com.apple.product-type.application"; }; + B044663F2638149900DAD616 /* SideDishAppTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = B04466472638149900DAD616 /* Build configuration list for PBXNativeTarget "SideDishAppTests" */; + buildPhases = ( + B044663C2638149900DAD616 /* Sources */, + B044663D2638149900DAD616 /* Frameworks */, + B044663E2638149900DAD616 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + B04466462638149900DAD616 /* PBXTargetDependency */, + ); + name = SideDishAppTests; + productName = SideDishAppTests; + productReference = B04466402638149900DAD616 /* SideDishAppTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 1E1DBAC6262DDDFC0050FE6C /* Project object */ = { isa = PBXProject; attributes = { - LastSwiftUpdateCheck = 1230; + LastSwiftUpdateCheck = 1240; LastUpgradeCheck = 1230; TargetAttributes = { 1E1DBACD262DDDFC0050FE6C = { CreatedOnToolsVersion = 12.3; }; + B044663F2638149900DAD616 = { + CreatedOnToolsVersion = 12.4; + TestTargetID = 1E1DBACD262DDDFC0050FE6C; + }; }; }; buildConfigurationList = 1E1DBAC9262DDDFC0050FE6C /* Build configuration list for PBXProject "SideDishApp" */; @@ -303,6 +367,7 @@ projectRoot = ""; targets = ( 1E1DBACD262DDDFC0050FE6C /* SideDishApp */, + B044663F2638149900DAD616 /* SideDishAppTests */, ); }; /* End PBXProject section */ @@ -314,11 +379,20 @@ files = ( 1E1DBADE262DDDFD0050FE6C /* LaunchScreen.storyboard in Resources */, 1ECF2E812632A70F006982BE /* LoadingView.xib in Resources */, + B044665D26383DD500DAD616 /* testData.json in Resources */, 1E1DBADB262DDDFD0050FE6C /* Assets.xcassets in Resources */, 1E1DBAD9262DDDFC0050FE6C /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; + B044663E2638149900DAD616 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B04466512638152200DAD616 /* testData.json in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ @@ -382,13 +456,31 @@ B0911EA42631AF3400D5EBEC /* DiffableProvider.swift in Sources */, B0911E6F262EA29200D5EBEC /* DishCardCell.swift in Sources */, 1E1DBAD4262DDDFC0050FE6C /* SceneDelegate.swift in Sources */, + B04466392637B17600DAD616 /* MockNetworkManager.swift in Sources */, 1ECF2E842632A862006982BE /* LoadingView.swift in Sources */, 1ECD5F73262F405100DC56C0 /* MenuListViewModel.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; + B044663C2638149900DAD616 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B044664D263814B400DAD616 /* NetworkTests.swift in Sources */, + B04466432638149900DAD616 /* SideDishAppTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXTargetDependency section */ + B04466462638149900DAD616 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 1E1DBACD262DDDFC0050FE6C /* SideDishApp */; + targetProxy = B04466452638149900DAD616 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + /* Begin PBXVariantGroup section */ 1E1DBAD7262DDDFC0050FE6C /* Main.storyboard */ = { isa = PBXVariantGroup; @@ -563,6 +655,48 @@ }; name = Release; }; + B04466482638149900DAD616 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = PSH4C5839A; + INFOPLIST_FILE = SideDishAppTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 14.4; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.Dahun-Lee.SideDishAppTests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SideDishApp.app/SideDishApp"; + }; + name = Debug; + }; + B04466492638149900DAD616 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = PSH4C5839A; + INFOPLIST_FILE = SideDishAppTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 14.4; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.Dahun-Lee.SideDishAppTests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SideDishApp.app/SideDishApp"; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -584,6 +718,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + B04466472638149900DAD616 /* Build configuration list for PBXNativeTarget "SideDishAppTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B04466482638149900DAD616 /* Debug */, + B04466492638149900DAD616 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ /* Begin XCVersionGroup section */ diff --git a/SideDishApp/SideDishApp/Application/AppDelegate.swift b/SideDishApp/SideDishApp/Application/AppDelegate.swift index ae80ca80c..3c208dde8 100644 --- a/SideDishApp/SideDishApp/Application/AppDelegate.swift +++ b/SideDishApp/SideDishApp/Application/AppDelegate.swift @@ -10,26 +10,6 @@ import CoreData @main class AppDelegate: UIResponder, UIApplicationDelegate { - - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - // Override point for customization after application launch. - return true - } - - // MARK: UISceneSession Lifecycle - - func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { - // Called when a new scene session is being created. - // Use this method to select a configuration to create the new scene with. - return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) - } - - func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { - // Called when the user discards a scene session. - // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. - // Use this method to release any resources that were specific to the discarded scenes, as they will not return. - } - // MARK: - Core Data stack lazy var persistentContainer: NSPersistentContainer = { /* diff --git a/SideDishApp/SideDishApp/Data/Network/MockNetworkManager.swift b/SideDishApp/SideDishApp/Data/Network/MockNetworkManager.swift new file mode 100644 index 000000000..78152cd06 --- /dev/null +++ b/SideDishApp/SideDishApp/Data/Network/MockNetworkManager.swift @@ -0,0 +1,46 @@ +// +// MockNetworkManager.swift +// SideDishApp +// +// Created by 이다훈 on 2021/04/27. +// + +import Foundation +import Combine + +protocol URLSessionProtocol { + func dataTaskPublisher(for url: URL) -> URLSession.DataTaskPublisher +} + +extension URLSession : URLSessionProtocol{ +} + +struct MockNetworkSessionSuccess : URLSessionProtocol { + func dataTaskPublisher(for url: URL) -> URLSession.DataTaskPublisher { + + return URLSession.shared.dataTaskPublisher(for: Bundle.main.url(forResource: "testData", withExtension: "json")!) + } +} + +class MockNetworkManager : NetworkManager { + override func get(url: URL?) -> AnyPublisher where T : Decodable { + + guard let myUrl = url else { + return Fail(error: NetworkError.urlError).eraseToAnyPublisher() + } + + return session.dataTaskPublisher(for: myUrl) + .mapError { _ in NetworkError.networkConnection } + .flatMap { data, response -> AnyPublisher in + return Just(data) + .decode(type: T.self, decoder: JSONDecoder()) + .mapError { error in + print(error.localizedDescription) + return NetworkError.parsing }.eraseToAnyPublisher() + }.eraseToAnyPublisher() + } + + +} + + diff --git a/SideDishApp/SideDishApp/Data/Network/NetworkManager.swift b/SideDishApp/SideDishApp/Data/Network/NetworkManager.swift index 9e36be94b..2ece4a2ad 100644 --- a/SideDishApp/SideDishApp/Data/Network/NetworkManager.swift +++ b/SideDishApp/SideDishApp/Data/Network/NetworkManager.swift @@ -14,15 +14,19 @@ protocol NetworkManageable { class NetworkManager: NetworkManageable { + let session: URLSessionProtocol + + init(session: URLSessionProtocol = URLSession.shared) { + self.session = session + } + func get(url: URL?) -> AnyPublisher where T: Decodable { guard let myUrl = url else { - return Fail(error: NetworkError.urlError).eraseToAnyPublisher() } - return URLSession.shared.dataTaskPublisher(for: myUrl) + return session.dataTaskPublisher(for: myUrl) .mapError { _ in NetworkError.networkConnection } - .flatMap { data, response -> AnyPublisher in guard let httpResponse = response as? HTTPURLResponse else { return Fail(error: NetworkError.responseNil).eraseToAnyPublisher() diff --git a/SideDishApp/SideDishApp/Domain/Entity/Dish.swift b/SideDishApp/SideDishApp/Domain/Entity/Dish.swift index 29b90eecb..7bffe0ca1 100644 --- a/SideDishApp/SideDishApp/Domain/Entity/Dish.swift +++ b/SideDishApp/SideDishApp/Domain/Entity/Dish.swift @@ -8,16 +8,37 @@ import Foundation // MARK: - Dishes -struct Dishes: Codable, Hashable { +struct Dishes: Codable, Hashable, Equatable { private(set) var category: String private(set) var name: String private(set) var dishes: [Dish] } // MARK: - Dish -public class Dish: NSObject, Codable, NSSecureCoding,NSCoding { +public class Dish: NSObject, Codable, NSSecureCoding, NSCoding { public static var supportsSecureCoding: Bool = true + init(dishID: String, + image: String, + alt: String, + deliveryType: String, + title: String, + dishDescription: String, + normalPrice: String, + sellingPrice: String, + badge: String) { + self.dishID = dishID + self.image = image + self.alt = alt + self.deliveryType = deliveryType + self.title = title + self.dishDescription = dishDescription + self.normalPrice = normalPrice + self.sellingPrice = sellingPrice + self.badge = badge + } + + public func encode(with coder: NSCoder) { coder.encode(dishID, forKey: "dishId") coder.encode(title, forKey: "title") diff --git a/SideDishApp/SideDishAppTests/Info.plist b/SideDishApp/SideDishAppTests/Info.plist new file mode 100644 index 000000000..64d65ca49 --- /dev/null +++ b/SideDishApp/SideDishAppTests/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/SideDishApp/SideDishAppTests/NetworkTests.swift b/SideDishApp/SideDishAppTests/NetworkTests.swift new file mode 100644 index 000000000..56c915907 --- /dev/null +++ b/SideDishApp/SideDishAppTests/NetworkTests.swift @@ -0,0 +1,34 @@ +// +// NetworkTests.swift +// SideDishAppTests +// +// Created by 이다훈 on 2021/04/27. +// +import XCTest +import Combine +@testable import SideDishApp + +class NetworkTests: XCTestCase { + private var sut: DishNetworkManager! + private var subScribtion = Set() + override func setUp() { + sut = DishNetworkManager.init(networkManager: MockNetworkManager(session: MockNetworkSessionSuccess())) + } + + func testDataTaskPublisher() { + let expt = expectation(description: "waiting......") + var result = [Dishes.init(category: "", name: "", dishes: [])] + let answer = Dishes.init(category: "test", name: "success", dishes: []) + + sut.getDishes(path: "test") + .sink(receiveCompletion: { response in + }, receiveValue: { data in + result = data + expt.fulfill() + }) + .store(in: &subScribtion) + waitForExpectations(timeout: 5.0, handler: nil) + XCTAssertEqual(result.first, answer) + } + +} diff --git a/SideDishApp/SideDishAppTests/SideDishAppTests.swift b/SideDishApp/SideDishAppTests/SideDishAppTests.swift new file mode 100644 index 000000000..c987af59b --- /dev/null +++ b/SideDishApp/SideDishAppTests/SideDishAppTests.swift @@ -0,0 +1,32 @@ +// +// SideDishAppTests.swift +// SideDishAppTests +// +// Created by 이다훈 on 2021/04/27. +// + +import XCTest + +class SideDishAppTests: XCTestCase { + + override func setUpWithError() throws { + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDownWithError() throws { + // Put teardown code here. This method is called after the invocation of each test method in the class. + } + + func testExample() throws { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. + } + + func testPerformanceExample() throws { + // This is an example of a performance test case. + measure { + // Put the code you want to measure the time of here. + } + } + +} diff --git a/SideDishApp/SideDishAppTests/testData.json b/SideDishApp/SideDishAppTests/testData.json new file mode 100644 index 000000000..9908b7064 --- /dev/null +++ b/SideDishApp/SideDishAppTests/testData.json @@ -0,0 +1,6 @@ +[{ + "category": "test", + "name" : "success", + "dishes" : [ + ] +}]