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

Mocks crashing when using NSUserActivity as parameter passed with any() #276

Open
mauronate opened this issue Jan 21, 2022 · 2 comments
Open
Labels
framework bug Breaks tests or user testing code more info needed Further information is requested

Comments

@mauronate
Copy link

mauronate commented Jan 21, 2022

New Issue Checklist

Overview

When using verify to check if a mocked function has been called, if such function accepts a NSUserActivity as a parameter passed , and it has been passed as any(), the unit tests project crashes raising on the current latest version (0.19.2) a Thread 1: EXC_BAD_ACCESS.

On 0.18.x the error is also present, but is handled so that the project does not crash resulting into a failing test with a provided description and highlighting the specific line where the exception is raised: -[NSProxy methodSignatureForSelector:] called! (NSInvalidArgumentException)

On the 0.17.0 version the tests proceed without any issue.

Example

Protocol Function example:
func scene(_ scene: UIScene, continue userActivity: NSUserActivity)

Code that raises the exception/error:
verify(mockBranchClient.scene(any(), continue: any())).wasNeverCalled()
verify(mockBranchClient.scene(any(), continue: any())).wasCalled()

Expected Behavior

The test should either succeed or fail by check if the verified function has been called or not with the passed parameters.

Environment

  • Xcode 13.2 Swift 5.5.2
  • Mockingbird set up using pods and using the CLI bundled with it.
  • Using Quick and Nimble
@mauronate mauronate added the framework bug Breaks tests or user testing code label Jan 21, 2022
andrewchang-bird added a commit to andrewchang-bird/mockingbird that referenced this issue Jan 21, 2022
andrewchang-bird added a commit to andrewchang-bird/mockingbird that referenced this issue Jan 21, 2022
@andrewchang-bird
Copy link
Contributor

Thanks for reporting. Unfortunately I wasn’t able to repro this crash (see the changes under Examples/CocoaPodsExample): https://github.com/andrewchang-bird/mockingbird/tree/repro-issue-276

Could you provide additional context or a minimal repro project for this?

@andrewchang-bird andrewchang-bird added the more info needed Further information is requested label Jan 21, 2022
@karlpuusepp
Copy link

@andrewchang-bird I also stumbled on the same issue in 0.20.0 trying to mock a protocol which references NSDecimalNumber.

I reproduced the crash with a basic example in a fresh Carthage project.

// App target
protocol NSProtocol {
  func calculateSomething(from: NSDecimalNumber) -> String
}

// In test
let m = mock(NSProtocol.self)
given(m.calculateSomething(from: any())) ~> "test" // any() crashes

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 more info needed Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants