Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stubbing base class of an extension. #298

Open
carles-estevadeordal opened this issue Apr 28, 2022 · 0 comments
Open

Stubbing base class of an extension. #298

carles-estevadeordal opened this issue Apr 28, 2022 · 0 comments
Labels
framework bug Breaks tests or user testing code

Comments

@carles-estevadeordal
Copy link

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...

@carles-estevadeordal carles-estevadeordal added the framework bug Breaks tests or user testing code label Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
framework bug Breaks tests or user testing code
Projects
None yet
Development

No branches or pull requests

1 participant