Skip to content

Instantly share code, notes, and snippets.

@ykpoh
Last active July 24, 2021 05:33
Show Gist options
  • Save ykpoh/59a150597d39f48fbef85dc38c8fe9cd to your computer and use it in GitHub Desktop.
Save ykpoh/59a150597d39f48fbef85dc38c8fe9cd to your computer and use it in GitHub Desktop.
import XCTest
@testable import SpaceXLaunch // 1
class LaunchResponseTests: XCTestCase, DecodableTestCase { // 2
var sut: LaunchResponse! // 3
override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
try super.setUpWithError()
try! givenSUTFromJSON() // 4
}
override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
sut = nil // 5
try super.tearDownWithError()
}
// MARK: - Type Tests
func testConformsToDecodable() { // 6
XCTAssertTrue((sut as Any) is Decodable) // cast silences a warning
}
func testConformsToEquatable() { // 7
XCTAssertEqual(sut, sut) // requires Equatable conformance
}
func testDecodableSetsDocs() { // 8
XCTAssertNotNil(sut.docs)
XCTAssertEqual(sut.docs?.count ?? -1, 2)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment