mockingbird
mockingbird copied to clipboard
Stubbing base class of an extension.
I have a simple extension to UIDevice that I wanted to test:
public extension UIDevice {
func isPad() -> Bool {
return self.userInterfaceIdiom == .pad
}
}
Mi test goes as follows:
func testIsPad() throws {
let device = mock(UIDevice.self)
// Stubbing
given(device.userInterfaceIdiom).willReturn(.pad)
print("value: \(device.userInterfaceIdiom)")
print(device.isPad())
XCTAssertTrue(device.isPad())
}
The thing is that this compiles just fine but it does not work, is there any way to accomplish this or it is just not possible, sorry for the novice question...