Skip to content

Instantly share code, notes, and snippets.

@ykpoh
Created July 24, 2021 04:55
Show Gist options
  • Save ykpoh/24f9f6f66889d4e38d99a7f8e80224c1 to your computer and use it in GitHub Desktop.
Save ykpoh/24f9f6f66889d4e38d99a7f8e80224c1 to your computer and use it in GitHub Desktop.
import Foundation
import XCTest
protocol DecodableTestCase: class {
associatedtype T: Decodable
var sut: T! { get set }
}
extension DecodableTestCase {
func givenSUTFromJSON(fileName: String = "\(T.self)") throws {
let decoder = JSONDecoder()
let data = try Data.fromJSON(fileName: fileName)
sut = try decoder.decode(T.self, from: data)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment