-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MERGE] API Unit Test 관련 파일들 추가 (#195)
- Loading branch information
Showing
6 changed files
with
190 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
LionHeart-iOS/LionHeart-iOSTests/Challenge/ServiceTests/ServiceTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// ServiceTests.swift | ||
// LionHeart-iOSTests | ||
// | ||
// Created by 김민재 on 11/28/23. | ||
// | ||
|
||
import XCTest | ||
|
||
final class ServiceTests: 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. | ||
// Any test you write for XCTest can be annotated as throws and async. | ||
// Mark your test throws to produce an unexpected failure when your test encounters an uncaught error. | ||
// Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards. | ||
} | ||
|
||
func testPerformanceExample() throws { | ||
// This is an example of a performance test case. | ||
self.measure { | ||
// Put the code you want to measure the time of here. | ||
} | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
LionHeart-iOS/LionHeart-iOSTests/URLSessionStub/JSONLoader.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// JSONLoader.swift | ||
// LionHeart-iOSTests | ||
// | ||
// Created by 김민재 on 11/28/23. | ||
// | ||
|
||
import Foundation | ||
|
||
final class JSONLoader { | ||
|
||
func load(fileName: String) -> URL { | ||
let bundle = Bundle(for: Self.self) | ||
guard let fileURL = bundle.url(forResource: fileName, withExtension: "json") else { | ||
return URL(fileURLWithPath: "") | ||
} | ||
return fileURL | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
LionHeart-iOS/LionHeart-iOSTests/URLSessionStub/URLSessionStub.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// URLSessionStub.swift | ||
// LionHeart-iOSTests | ||
// | ||
// Created by 김민재 on 11/28/23. | ||
// | ||
|
||
import Foundation | ||
@testable import LionHeart_iOS | ||
|
||
final class URLSessionStub: LHURLSession { | ||
|
||
private var data: Data? | ||
|
||
init(data: Data? = nil) { | ||
self.data = data | ||
} | ||
|
||
func data(for request: URLRequest) async throws -> (Data, URLResponse) { | ||
return (data ?? Data(), URLResponse()) | ||
} | ||
} |